Forum Discussion
power bi Table Visuilation in R
Hey,
I guess you have to load the R package that enables the usage of piping.
I use the package magrittr.
I guess your are using R studio as dev ide, within R studio some packages do not have to be explicitly loaded.
Add the line
library("magrittr") to your R script that you are using in Power BI and I assume it will work.
Regards
Yes Right I am Using Rstudio only.
I have added below line.But Still I am getting error.
library("magrittr")
COuld you please help me the correct code in Power Bi with R.
PLease find below code which I have Use In Power bi.
options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))
library("magrittr")
# style V6 based on values of V6
datatable(df) %>% formatStyle(
'V6',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)
- TomMartens9 years agoSuper User
Hey,
there is bad news,
- the minor thing, you also have to reference the library DT using library("DT")
- the major thing, the function datatable returns an HTML widget, currently the R script visual inside Power BI just supports objects of typ plots, this means that you currently can't achieve what you are looking for using the DT approach, unless you are willing to create a Custom R visual (no it's some same as the R script visual, you can start here: https://github.com/Microsoft/PowerBI-visuals/tree/master/RVisualTutorial)
Maybe you have to rethink, and give the function tableGrob from the gridExtra a try. Additional information is available here:
https://cran.r-project.org/web/packages/gridExtra/vignettes/tableGrob.html
This is what I'm using :-)
Regards
Regards