Error while formatting using DT

I am trying to format an output using DT formatting. I have a column pct in the dataframe ab() which I am formatting with the code below

 abc<- reactive ({datatable(ab()) %>% formatStyle('pct',
                               background = styleColorBar(range('pct'), 'lightblue'),
                              backgroundSize = '98% 88%',
                               backgroundRepeat = 'no-repeat',
                              backgroundPosition = 'center')})

The error I get here is non-numeric argument to binary operator . What could I be missing here.Thank you.

You're passing the text value 'pct' to range(), instead of a vector. Try

background = styleColorBar(range(ab()[['pct']]), 'lightblue')

Or dollar-sign syntax: range(ab()$pct)

1 Like