0

I have a bit of code from a shinyapp that determines what will be exported to a pdf document:

  special_ortho_table <- reactive({
    if(input$ortho == "yes"){
      sp_ortho_table <- drugsUI %>%
        filter(Ortho == "yes", Special_ortho == TRUE) %>% 
       select(Name, Recommendations)
     }else{
       sp_ortho_table <- drugsUI[0,]
       names(sp_ortho_table) <- c("", "", "", "")
       }

    return(sp_ortho_table)
  })

 output$ortho_table <- renderTable({
    xtable(special_ortho_table())
  })

The corresponding code in rmd is:

xtable(special_ortho_table())

You can see that I tried to remove the column names but the pdf still produces a blank table with horizontal borders. Is there any way that I can remove the borders, if not, can anyone suggest a work around that would allow me to leave something that is blank when input$ortho == "no"?

Edit:

The following picture showed what I wish to remove which is the remnants of essentially a blank xtable output on the pdf:

enter image description here

Larry Li
  • 73
  • 6
  • "You can see that I tried to remove the column names" We can't see anything, and this isn't a complete enough example to run the code. Can you just isolate the `xtable` part from everything Shiny-related in order to build a workable example here? – camille Nov 20 '19 at 17:19
  • Apologies for not being clear, I will edit my question. The "remove the column names" is implied by the code `names(sp_ortho_table) <- c("", "", "", "")` where they are intentionally left blank – Larry Li Nov 20 '19 at 19:06
  • 1
    Perhaps you have to put `hline.after = NULL` in `renderTable`. Please provide a minimal reproducible example if that does not work, so that we can help. – Stéphane Laurent Nov 20 '19 at 22:11
  • That's great, working as expected, for some reason this didn't work when I tried it before with`print(xtable(sp_ortho_table(), hline.after = NULL))` but then I saved `sp_ortho_table()` as a separate object and that's working, many thanks – Larry Li Nov 21 '19 at 09:06

0 Answers0