I'm attempting to export a kable table (latex) to a .pdf file using R Shiny.
Here is the code I am using to generate the kable latex table:
x<-kable(overall, align = c('l', 'c', 'c', 'c', 'c', 'c', 'c'), "latex", booktabs = T,
caption = "Sample Table",
escape = FALSE)%>%
kable_styling(latex_options = c("striped")) %>%
add_header_above(c(" " = 1, 'Group 1' = 3, 'Group 2' = 3))%>%
landscape()
save_kable(x, 'SampleTable.pdf')
I'm able to export this in a standalone R program, but I'd like to replicate the export with R Shiny. I attempted to wrap the code in the downloadHandler function, but it doesn't work.
Sample code:
output$export = downloadHandler(
filename = function() {"sampleTable.pdf"},
content = function(file) {
x<-kable(overall, align = c('l', 'c', 'c', 'c', 'c', 'c', 'c'), "latex", booktabs = T,
caption = "Sample Table",
escape = FALSE)%>%
kable_styling(latex_options = c("striped")) %>%
add_header_above(c(" " = 1, 'Group 1' = 3, 'Group 2' = 3))%>%
landscape()
save_kable(x, file)
}
)
Any insight would be appreciated.