Hello All,
I am relatively new to Shiny and reactivity. Here I try to create an app which:
1 - Selects a folder
2 - Selects a file in that folder
3 - Uploads and processes that file.
I have gone this far:
ui.R
filler_box <- box( title = "Auto-filler",
status = "primary", solidHeader = TRUE,
width = 12,
column(1,
shinyDirButton("ms_folder",
"Select folder",
"Select a project folder")
),column(4,
verbatimTextOutput("selected_ms_dir")),column(1,
shinyFilesButton(
id = "select_ms_file",
label = "Select file",
title = "Please select the MS data sheet file:",
multiple = F)
),column(4,
verbatimTextOutput("selected_ms_file")),
server.R
shinyDirChoose(input, "ms_folder", roots = roots, session = session)
selected_ms_folder <- reactive({
parseDirPath(roots, input$ms_folder)
})output$selected_ms_dir <- renderPrint({
if (is.integer(input$ms_folder)) {
cat("No folder selected")
} else {
selected_ms_folder()
}
})selected_ms_file <- reactive({
shinyFileChoose(
input = input, "select_ms_file",
roots = c("path" = selected_ms_folder()),
session = session)req(input$select_ms_file, selected_ms_folder()) return(input$select_ms_file) })
observeEvent( selected_ms_file(),
{print(str(input$select_ms_file))})output$selected_ms_file <- renderPrint({
if (is.integer(input$select_ms_file)) {
cat("No files selected")
} else {
selected_ms_file()
}})
Not sure what to expect from "input$select_ms_file", but it is a nested list.
I tries to use "parseFilePaths()" but it returns NA.
Couls someone please help me correct this?
Thanks,