16

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"])
}  
})
rrbest
  • 1,619
  • 3
  • 14
  • 22
  • 3
    `renderTable` has a `...` which passes options to `xtable`. `xtable` has an `include.rownames` options. Try using `include.rownames = FALSE` as an option in `renderTable` – jdharrison Dec 19 '13 at 01:38

4 Answers4

35

this instruction is working for me

output$summaryTable <- renderTable({
       df()$donnees         
    }, 
    include.rownames=FALSE)
Rohan Kandwal
  • 9,112
  • 8
  • 74
  • 107
Hazem HASAN
  • 1,598
  • 2
  • 21
  • 38
5

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.

userJT
  • 11,486
  • 20
  • 77
  • 88
0

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

Dev Patel
  • 292
  • 1
  • 5
  • 12
  • I have added row.names=NULL and it had no impact on the shiny output. – rrbest Dec 18 '13 at 22:23
  • @rrbest I haven't tried it with shiny but it worked for me with my regular code. I think to write some test code for shiny would take some effort. Is it possible if you can paste your code/snippet for both ui.R and server.R. – Dev Patel Dec 18 '13 at 23:08
0

This will work

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