Hi R experts,
Please run the code below:
datatable(iris) %>%
formatStyle('Sepal.Length', fontWeight = styleInterval(5, c('normal', 'bold'))) %>%
formatStyle(
'Sepal.Width',
color = styleInterval(c(3.4, 3.8), c('white', 'blue', 'red')),
backgroundColor = styleInterval(3.4, c('gray', 'yellow'))
) %>%
formatStyle(
'Petal.Length',
background = styleColorBar(iris$Petal.Length, 'steelblue'),
backgroundSize = '100% 90%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center'
) %>%
formatStyle(
'Species',
transform = 'rotateX(45deg) rotateY(20deg) rotateZ(30deg)',
backgroundColor = styleEqual(
unique(iris$Species), c('lightblue', 'lightgreen', 'lightpink')
)
)
Now, lets say, we want to have 4 intervals in Sepal.Width. (< 0, Until 50, More than 100, Inf).
I tried
datatable(iris) %>%
formatStyle('Sepal.Length', fontWeight = styleInterval(5, c('normal', 'bold'))) %>%
formatStyle(
'Sepal.Width',
backgroundColor = styleInterval(c(0, 50,100,Inf), c('white', 'blue', 'red', 'green','yellow'))
)
i.e
Values below 0 in Sepal.Width column would be White
Value between 0 and 50 in the Sepal.Width column would be Blue
Value between 50 and 100 in the Sepal.Width column would be Red
Value between 100 and Inf in the Sepal.Width column would be Green
Values more than Infinite in the Sepal.Width column would be Yellow
But Infinity values in the column is not recognized in the column and Color is not recognized or had any backgroundcolor.
Thanks in advance
Abi