I am trying to get the output from R grviz on a powerPI R-Visual. My code to generate a simple tree:
library(DiagrammeR)
vector <- c('A->1','A->2')
df = data.frame(vector)
grViz(paste0("digraph boxes_and_circles {", paste0(df$vector, collapse = " "), "}"))
I noticed in R Studio, that the output of grviz is in the viewer and not the plot:
In Power BI, I get the following Error Message:
No image was created. The R code didn't result in creation of any visuals. Make sure your R script results in a plot to the R default device.
Is this a shortcoming in PowerBI? How can I get this to display in the R-Visual in PowerBI?
It appears that you must render the graphViz graphic into a PNG in PowerBi. I used the following line of code after creating the graph:
library(DiagrammeRsvg)
library(rsvg)
library(png)
graph <- {Statements}
tmp <- capture.output(rsvg_png(charToRaw(export_svg(grViz(graph) )),'image.png'))