Exclude row names from R Shiny renderTable

一笑奈何 提交于 2019-12-12 08:22:37

问题


I am using the renderTable function from the R Shiny package and it is returning a table with row names. Ideally I want a table to be displayed with only two columns, one for 'Month' and one for 'Value'. The output I currently get includes the row names. I have tried a few things to exclude row names but was unsuccessful. Any thoughts?

output$valueTable <- renderTable({
if(input$table_view == TRUE){
  data.frame(Month = Month(), Value = valueData()[,"Value"])
}  
})

回答1:


this instruction is working for me

output$summaryTable <- renderTable({
       df()$donnees         
    }, 
    include.rownames=FALSE)



回答2:


Into your init code, put

options(xtable.include.rownames=F)
options(xtable.include.colnames=F)

this will disable it for all tables in your app.




回答3:


I think you need to include row.names=NULL inside your data.frame call.

data.frame(Month = Month(), Value = valueData()[,"Value"], row.names=NULL)

If you already have a data frame(df), then you could do: row.names(myDF) <- NULL




回答4:


This will work

output$valueTable <- renderTable({
   if(input$table_view == TRUE){
      data.frame(Month = Month(), Value = valueData()[,"Value"])
   }  
}, rownames = FALSE)


来源:https://stackoverflow.com/questions/20669150/exclude-row-names-from-r-shiny-rendertable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!