Hey, I have a similar problem as here:
saveWidget function in an old script - R Markdown - Posit Community (rstudio.com)
The difference is, that I have pandoc installed and when I am running my shiny app via RStudio, there is no issue, everything works as intended.
But when I am running the script through a bat file shortcut, I get the error from the browser: "Couldn't download, something went wrong..."
And in the logs its stating: "Warning: Error in pandoc_self_contained_html: Saving a widget with selfcontained = TRUE requires pandoc. See here to learn more 1.1 Use a Pandoc version not bundled with the RStudio IDE | R Markdown Cookbook
1: shiny::runApp"
The application:
library(shiny)
library(ggplot2)
library(plotly)
library(htmlwidgets)
ui <- fluidPage(
downloadButton("downloadData", "Download")
)
server <- function(input, output) {
data <- mtcars
plot1 <- ggplot2::ggplot(mtcars, aes(x = cyl, y = hp))+
geom_point()
plot <- ggplotly(plot1)
output$downloadData <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".html", sep="")
},
content = function(file) {
htmlwidgets::saveWidget(plot, file, selfcontained = T)
}
)
}
shinyApp(ui, server)
And my bat file:
"C:/Program Files/R/R-4.2.0/bin/R.exe" -e "shiny::runApp('C:/Users/user/Desktop/Download.R', launch.browser = TRUE)"
Many thanks