Hi Nuno.Nogueira,
the problem is mostly the initial directory, you can specify it with the setwd()/getwd() which you specified here:
global <- reactiveValues(datapath = getwd())
I would instead suggest this, way more simpler and gives more functionalityimo.:
library(shiny)
library(stringr)
ui <- fluidPage(
mainPanel(
fileInput("file",
label = "",
multiple = TRUE,
accept = c(".xlsx")
)
))
server <- function(input, output) {
observeEvent(input$file, {
infile <- input$file
if (is.null(infile)) {
return(NULL)
} else {
numfiles <<- nrow(infile)
}
for (i in 1:numfiles) {
if(str_detect(input$file$datapath[i], ".xlsx")){
tryCatch(
{
Data <- read_excel(input$file$datapath[i], sheet = "") # specified what you want to import
assign(paste("Data", i, sep = "_"), # gave unique name
Data,
envir = .GlobalEnv
)
},
error = function(e) {}
)
}
}
})
}
# Run the application
shinyApp(ui = ui, server = server)