I want to launch a shiny application from a terminal. My application has a button that when pressed opens a window to select a folder with the function rstudioapi::selectDirectory()
But when i click on the button i get this error:
$ "Rscript.exe" -e "shiny::runApp('Shiny/app.R')"
Loading required package: shiny
Warning: package 'shiny' was built under R version 3.5.3
Listening on http://127.0.0.1:6283
Warning: Error in : RStudio not running
76: stop
75: verifyAvailable
74: callFun
73: rstudioapi::selectDirectory
72: observeEventHandler [D:/Users/folder/Shiny/app.R#12]
1: shiny::runApp
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
actionButton("folder", "Choose folder")
)
server <- function(input, output) {
observeEvent(input$folder, {
path.file <- rstudioapi::selectDirectory()
print(path.file)
})
}
# Run the application
shinyApp(ui = ui, server = server)