Reputation: 611
I have folders(A,B,C) and files(a,b,c). The folders are all in the same directory.
Each folder has all the files.
Example: FolderA has files(A-a,A-b,A-c), FolderB has files(B-a,B-b,B-c) and FolderC has files(C-a,C-b,C-c).
So, I want to show a list of these.
This is the output what I want:
When I select Folder B, I want to show the file list for Folder B on (Smaller Category)-selectInput
. And if I press the action button, I want to use the reactive function to process the data for that path(Folder B/CsvFile B-c).
global.R
getFromGlobalR <- memoise(function(path){
execution code...
}
ui.R
fluidPage(
titlePanel("selectInput"),
fluidRow(
uiOutput("larger_category"),
uiOutput("smaller_category"),
uiOutput("action_btn")
)
)
server.R
executed_statement <- reactive({
input$action_btn
isolate({
if(input$smaller=="") return()
getFromGlobalR(input$smaller)
})
})
output$larger_category <- renderUI({
selectInput("larger", "select folder", choices =list.dirs(path = "./FolderDir", full.names = FALSE, recursive = FALSE))
})
output$smaller_category <- renderUI({
selectInput("smaller", "select files", choices = ?)
})
output$action_btn <- renderUI({
actionButton("actionBtn", class="btn-primary", "search")
})
I don't know what to put in the choices
parameter for output$smaller_category
.
I tried to use choices=list.files(paste("./",input$larger,sep=""), ".csv")
. But It's not worked.
Also, I don't know if it works fine even if I put the choices
parameter in output$smaller_category
.
Any ideas?
Upvotes: 0
Views: 406
Reputation: 1731
Debugging
First of all you need to debug and see your values by using browser()
or printing the values, for example:
In the server output$d <- renderPrint(input$larger)
In the ui verbatimTextOutput("d")
Possible Issues
selectInput
defaults to the first value for single-select lists if selected
is not set.
If FolderDir
is reactive, it will have an effect.
Upvotes: 1