Save Static Insight using dkuSaveInsight()
Hi,
I want to save a rpart plot (through a R recipe) as a static insight to publish it in a dashboard. I have found from this documentation that by using the dkuSaveInsight(), one can save any R plot as a static insight. However, the documentation provided is not very explanatory. Any ideas/help on this would be highly appreciated! Thank you in advance!
-Konstantina
Answers
-
JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 296 Dataiker
Hi @konathan
,There is an academy course that includes code samples using R APIs to save insights: https://academy.dataiku.com/visualization-course/799354
If using ggplot2, here is an example of how you can quickly save a plot to your insights:
library(dataiku) library(ggplot2) df <- dkuReadDataset("credit_card_clients_prepared", samplingMethod="head", nbRows=10000) gg <- ggplot(df, aes(x="age", y="default_on_payment")) + geom_line(color="blue")+ geom_point() dkuSaveGgplotInsight("default-plots-by-age", gg)
Thanks!
Jordan
-
Konstantina Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 27 ✭✭✭✭✭
Hi @JordanB
!,Thank you for the resource! However, I have already studied this course and it cannot provide a solution to my problem. The reason is that I am not using any of these libraries for the tree plot. More specifically, I am using the rpart.plot() function.
-Konstantina
-
JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 296 Dataiker
Hi @konathan
,Have you tried to apply the following code (from the course) to your rpart.plot()?
dataiku.insights.save_data('chart_prices', payload=chart_prices_insight, content_type= 'text/html' , label=None, encoding='base64')
Thanks,
Jordan
-
Konstantina Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 27 ✭✭✭✭✭
Hi @JordanB
,Happy New Year!
Thank you for the suggestion! I have already tried to use the R equivalent code I found here (our solution is implemented in an R recipe). However, it doesn't seem to work for this type of object and I was not able to find further documentation on this matter. -Konstantina
-
Konstantina Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 27 ✭✭✭✭✭
For anyone interested, I have found a workaround solution on this problem - I have created the exact same visual in an RMarkdown report and then, publish it to a Dashboard. Right after the opening ''', in order to avoid the R code from showing up in the report, do not forget to use this line:
{r echo=FALSE, warning=FALSE, message=FALSE}
I hope this helps!
-Konstantina