Forum Discussion
power bi Table Visuilation in R
This depends your dataset and your logic for conditional formatting. See these similar threads below:
https://stackoverflow.com/questions/18663159/conditional-coloring-of-cells-in-table
https://stackoverflow.com/questions/31323885/how-to-color-specific-cells-in-a-data-frame-table-in-r
Also refer to code in following articles:
Conditional Formatting of a Table in R
More Examples on Styling Cells, Rows, and Tables
Regards,
HI,
Thank you for giving reply.
I am trying to Create Conditional color in grid using below code.but I am getting small error.that is "could not find function "%>%"" Please help me out .how to resolve it.
library(DT)
options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))
# style V6 based on values of V6
datatable(df) %>% formatStyle(
'V6',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)
- indu9 years agoHelper II
HI,
I have tried in R Language.It is working fine.But I need in Power bi Desktop with R.
I have tried with same code in Power bi Desktop.
It is Coming error like "error: could not find function "%>%" pipe"
PLease help me out.
- TomMartens9 years agoSuper User
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
- indu9 years agoHelper II
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'))
)