如何删除使用 renderTable 输出的 R 闪亮数据框中的 header 行?

How to delete header row in R shiny dataframe being output using renderTable?

如何删除table中的header行?我正在使用 renderTable 输出 table 并将 colnames 设置为空字符串。 colnames(df) <- c("", "")

colnames(df) <- c("","") 在这里没有做你想做的。你想要 colnames = FALSE 在你的 renderTable() 通话中。

这是一个简单的例子。请注意,无论是否使用 colnames<- 行,结果都是相同的。我可以用 colnames = TRUE

复制你的图像

library(shiny)
ui <- fluidPage(
    flowLayout(
        mainPanel(
           tableOutput("testTable")
        )
    )
)
server <- function(input, output) {
    dat <- data.frame(a = c(1,2,3),b = c(4,5,6),c = c(7,8,9))
    colnames(dat) <- c("","","")
    output$testTable <- renderTable(dat, colnames = FALSE, bordered = TRUE)
}
shinyApp(ui = ui, server = server)