Hello, Dear R Community I need your help regarding shiny. I am getting error downloading report when app is deployed on shiny and rsconnect. But locally it is working fine. I have attched the log
library(shiny)
library(sdcMicro)
ui <- fluidPage(
titlePanel("Sample SDC Report"),
uiOutput("ui_export_report")
)
server <- function(input, output) {
data(testdata)
sdcObj <- createSdcObj(
testdata,
keyVars = c('urbrur', 'roof', 'walls', 'water', 'electcon', 'relat', 'sex'),
numVars = c('expend', 'income', 'savings'), w = 'sampling_weight'
)
output$ui_export_report <- renderUI({
fluidRow(column(12,
shiny::downloadButton("myRepDownload", "Save report", btn.style = "primary"), align = "center"
))
})
output$myRepDownload <- shiny::downloadHandler(
filename = function() {
paste0("sdcreport-", Sys.Date(), ".html")
},
content = function(file) {
sdcMicro::report(
sdcObj,
outdir = tempdir(),
filename = "tmp",
title = "SDC-Report",
internal = TRUE,
verbose = FALSE
)
f_tmp <- file.path(tempdir(), "tmp.html")
on.exit(file.remove(f_tmp))
file.copy(from = f_tmp, to = file)
}
)
}
shinyApp(ui = ui, server = server)