Currently I have this simple R shiny app, to run it I open up RStudio and execute
library(shiny)
ui <- fluidPage(
# input - your name
textInput("name", "What's your name?"),
# show name
textOutput("greeting"),
hr(),
# create reprot
downloadButton("CreateReport",
"Create report"),
)
server <- function(input, output, session) {
output$greeting <- renderText(paste0("Hello ", input$name, "!"))
output$CreateReport <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = "Report.html",
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path(getwd(), "Report.Rmd")
file.copy("ReportC.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(
name = input$name
)
# create report
rmarkdown::render(tempReport,
output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)
}
# Run the application
shinyApp(ui = ui, server = server)
the Rmd file look like this
---
title: "Simple rest report "
author: ""
date: ""
output: html_document
params:
name: ""
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
Hello r params$name
This code works perfect when i run it from Rstudio. When i run the code from a batch file it gives a an error: server problem
The bat file has the following content:
"C:\Program Files\R\R-3.6.2\bin\R.exe" -e "shiny::runApp('app.R', launch.browser = TRUE)"
pause
The bat is is the same folder at the shiny app. The error showing at the download in the download pane in Chrome:
Failed - Serverproblem
I have been looking at at the web for similar cases on how to run Rshiny with rmarkdown , without luck. Please help.