我试图只为表中的所有数据显示两位小数,然后将所有内容集中对齐。第一列是国家,但其余是数字。这是代码
output$Composite <- renderDataTable(FVI_DATA_COMPOSITE, options = list(pageLength = 15,lengthChange=FALSE))
Run Code Online (Sandbox Code Playgroud)
任何想法如何做到这一点?
编辑:这不起作用。
output$Composite <- renderDataTable(FVI_DATA_COMPOSITE,
options = list(pageLength = 10,lengthChange=FALSE), round(FVI_DATA_COMPOSITE[3:9], digits=2)
Run Code Online (Sandbox Code Playgroud)
output$Composite <- renderDataTable(datatable(FVI_DATA_COMPOSITE,
options = list(pageLength = 10,lengthChange=FALSE)) %>% formatRound(c(3:9), 2)
Run Code Online (Sandbox Code Playgroud)
编辑:居中对齐
output$Composite <- renderDataTable(datatable(FVI_DATA_COMPOSITE,
options = list(pageLength = 10,lengthChange=FALSE)) %>%
formatRound(c(3:9), 2) %>%
formatStyle(columns = c(3:9), 'text-align' = 'center')
Run Code Online (Sandbox Code Playgroud)
接受的答案的代码模式不断返回以下警告/错误:
Warning: Error in : object of type 'closure' is not subsettable
我不得不在 Shinyapp.R
文件中使用稍微不同的模式:
server <- function(input, output) {
output$dtable <- DT::renderDataTable({
datatable(FVI_DATA_COMPOSITE) %>%
formatRound(columns = c(3:9), digits = 2)
})
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3447 次 |
最近记录: |