R应用于列子集的闪亮样式ColorBar

R应用于列子集的闪亮样式ColorBar,r,shiny,dt,R,Shiny,Dt,我在一个R闪亮的应用程序中有一个datatable,我正在尝试执行以下手册中所示的操作:->设置一个完整表格的样式。 但是,在本例中,我仅尝试自定义第2列和第3列的颜色 我的代码如下: datatable(df, filter = 'none', rownames= FALSE, caption = paste0("Execution Alpha by sector."

我在一个R闪亮的应用程序中有一个datatable,我正在尝试执行以下手册中所示的操作:->设置一个完整表格的样式。 但是,在本例中,我仅尝试自定义第2列和第3列的颜色

我的代码如下:

datatable(df, 
                  filter = 'none',
                  rownames= FALSE,
                  caption = paste0("Execution Alpha by sector."),
                  options = list(scrollX = F
                                 #,dom = 'ft'
                                 , lengthChange = T
                                 , pagingType = "numbers"  # this hides the Next and Previous buttons -->  https://datatables.net/reference/option/pagingType
                                 , autoWidth = T
                                 ,pageLength = 20 # this determines how many rows we want to see per page
                                 , info = FALSE #  this will hide the "Showing 1 of 2..." at the bottom of the table -->  https://stackoverflow.com/questions/51730816/remove-showing-1-to-n-of-n-entries-shiny-dt
                                 ,searching = FALSE  # this removes the search box  ->  https://stackoverflow.com/questions/35624413/remove-search-option-but-leave-search-columns-option
                  ))  %>%
                      formatStyle(                            
                        colnames(df)[2:3],
                        background = styleColorBar(df[,2:3], 'lightblue'),
                        backgroundSize = '100% 80%',
                        backgroundRepeat = 'no-repeat',
                        backgroundPosition = 'left' # center
                      )
我得到一个错误:“仅在包含所有数值变量的数据帧上定义”,但是第2列和第3列中的所有值都是数字。
有什么建议吗?谢谢

使用
样式颜色条(范围(df[,2:3]),“浅蓝色”)
这太完美了,谢谢@HubertL