16
votes

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"])
}  
})
4
renderTable has a ... which passes options to xtable. xtable has an include.rownames options. Try using include.rownames = FALSE as an option in renderTablejdharrison

4 Answers

35
votes

this instruction is working for me

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

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.

0
votes

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

0
votes

This will work

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