'Shiny app downloads kable in Rstudio cloud but not locally
I have a strange issue. The app below works normally and downloads the kable() as pdf when running in Rstudio cloud but does not download something when running locally in browser mode.
library(shiny)
library(knitr)
library(kableExtra)
options(knitr.table.format = "latex") # not required in newer versions of kableExtra
server <- function(input, output) {
# Fill in the spot we created for a plot
output$export = downloadHandler(
filename = function() {"sampleTable.pdf"},
content = function(file) {
x <- kable(head(iris), format = "latex", caption = "Title of the table")
save_kable(x, file)
},
contentType = 'application/pdf'
)
}
ui <- fluidPage(
# Give the page a title
titlePanel("Telephones by region"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
shiny::downloadButton("export", "Export")
),
# Create a spot for the barplot
mainPanel(
)
)
)
shinyApp(ui = ui, server = server)
the sessionInfo of my pc
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
system code page: 65001
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.37 kableExtra_1.3.4
compared to Rstudio cloud
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8
[5] LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] kableExtra_1.3.4 knitr_1.37 shiny_1.7.1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
