【发布时间】:2019-08-09 07:34:21
【问题描述】:
我想知道是否有办法从 Shiny 的数据表中删除索引列(第一列)。
例如 Name 列之前的 (1, 2, 3) 列,如下图所示:
下面是我的代码:
header <- dashboardHeader(
title = "Test"
)
sidebar <- dashboardSidebar(
)
body <- dashboardBody(
box(title = "Test", width = 7, status = "warning", DT::dataTableOutput("df"))
)
# UI
ui <- dashboardPage(header, sidebar, body)
# Server
server <- function(input, output, session) {
output$df = DT::renderDataTable(df, options = list(
autoWidth = TRUE,
columnDefs = list(list(width = '10px', targets = c(1,3)))))
}
# Shiny dashboard
shiny::shinyApp(ui, server)
提前致谢。
【问题讨论】:
-
为什么不在渲染的时候把它索引出来,
DT::renderDataTable(df[-1], ...)