I have an RShiny app that builds a number of plots based on input data. Currently I am using a selectInput widget that allows the user to choose a data source (sources are all csv files located in the same directory as the app) - the app then performs a read.csv on the selected source and creates the plots. Currently there are only two files to choose from, but soon there will be at least ten. Here's a sample of the relevant code:
UI:
selectInput("sample", label=h4("Select pre-loaded data to view"),
choices=c('sample 1', 'sample 2'), selected='sample 1',
multiple=FALSE),
Server:
load_data <- reactive({
if (input$sample == "sample 1") {
df <- read.csv('sample1.csv')
umap_df <- read.csv('sample1_umap.csv')
} else {
df <- read.csv('sample2.csv')
umap_df <- read.csv('sample2_umap.csv')
}
selected_data <- list()
selected_data$df <- df
selected_data$umap <- umap_df
return(selected_data)
})
I now want to update the app so that the user can select multiple data sources at a time to compare their plots. I know the first step is changing selectInput
to include multiple=TRUE
, but how can I parse multiple input$sample
values in my load_data function?