Hi all! I wrote an app that among other things should read a bunch of files and move them from the directory where they lived into an archive directory. The app runs on a Linux based R server. I wrote the function to move the files and placed it within a sourced helpers.R file. The function looks like this:
move_function <- function(x) {
fs::file_move(paste("/path/to/PAP_Ankündigungen", x, sep = "/"),
paste("/path/to/PAP_Ankündigungsarchiv", x, sep = "/"))
}
And here is an MRE of the app:
library(shiny)
source("/home/path/to/helpers.R")
setwd("/home/path/to/app")
# Define UI for application
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
actionButton("move", "Move")
),
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic
server <- function(input, output) {
observeEvent(input$move, {
filelist <- list.files("/path/to/PAP_Ankündigungen")
lapply(filelist, move_function)
})
}
# Run the application
shinyApp(ui = ui, server = server)
If I run the function outside of Shiny, the files move without problems, but I can't for the life of me understand what I am doing wrong within Shiny...
If anyone has an idea, I would be very thankful!
Cheers!