I am creating a Shiny app that needs to access a user's working directory. I assumed getwd() would work from within the Shiny app, however this always points to the directory of the Shiny app itself.
Example:
From the R console:
setwd("~/Documents")
getwd()
[1] "/Users/chris.harrison/Documents"
From the following Shiny app saved on the desktop:
library(shiny)
ui <- fluidPage(
verbatimTextOutput("wd")
)
server <- function(input, output){
output$wd <- renderText(getwd())
}
shinyApp(ui = ui, server = server)
And then calling:
setwd("~/Documents")
shiny::runApp("~/Desktop/app.R")
the output is:
/Users/chris.harrison/Desktop
Is there any way to call the user's working directory from within the app?
Many thanks,
Chris