I am looking to color format each numeric column so that it shows a blue range bar depending on the range of each column. Here is a photo on what I am trying to achieve.
#Here is the the table I have so far.
#I am adding filters to the columns. This works great
library(DT)
library(magrittr)
df = datatable(iris, filter = 'top', options = list(pageLength = 5, autoWidth = TRUE))
#I try to add the blue bars here to the first 2 numeric columns
df %>%formatStyle(names(df)[1:2],
background = styleColorBar(range(df[,1:2]), 'lightblue'),
backgroundSize = '98% 88%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center')
Error in df[, 1:2] : incorrect number of dimensions
It would also be nice if there was a function to automatically place the blue bars on all numeric columns. Thanks in advance