pre-loaded multi data set
Closed this issue · 5 comments
Hi
First, thank you a lot for this application, and for your supplemental articles describing how host it on shinyapps.io, control access with a login page, etc.
I have a question concerning an application hosted on shinyapps.io. I uploaded it with a pre-loaded data set. Would it be possible to put several datasets, and to be able to select them from the home page?
Best,
Marc
Hi @mdidish,
Thanks for the feedback! What you are asking for is currently not implemented, but I don't think it would be a lot of work to do it. Since it's a particular feature and there are a few other things on my to-do list that more people will benefit from, I can't give it a high priority. But if you are familiar with R and maybe even Shiny, you should be able to put something together without much effort. Essentially, you would replace the UI element that allows the user to select a dataset from a file with another UI element that allows the user to select between a few specific datasets (selectInput()
) and then load the selected dataset. You can see a very basic example here: https://shiny.rstudio.com/gallery/telephones-by-region.html
Does that help?
Best,
Roman
Thank you for your advice. I tried to replace in file shiny/v1.3/load_data/select_file.R
:
fileInput(
inputId = "input_file",
label = "Select input data (.crb or .rds file)",
multiple = FALSE,
accept = c(".rds",".crb",".cerebro"),
width = '350px',
buttonLabel = "Browse...",
placeholder = "No file selected"
)
by
selectInput(
inputId = "input_file",
label = "Select dataset:",
choices = c("Dataset 1" = "extdata/v1.3/cerebro_dataset1.crb",
"Dataset 2" = "extdata/v1.3/cerebro_dataset2.crb")
)
and in shiny_server.R
, I replace
observeEvent(input[['input_file']], ignoreNULL = FALSE, {
if (
!is.null(input[["input_file"]]) &&
!is.na(input[["input_file"]]) &&
file.exists(input[["input_file"]]$datapath)
) {
new_path <- input[["input_file"]]$datapath
by
observeEvent(input$input_file, ignoreNULL = FALSE, {
if (
!is.null(input$input_file) &&
!is.na(input$input_file) &&
file.exists(input$input_file)
) {
new_path <- input$input_file
but application crashes at launch.
Do you have any other advice? Otherwise I will see if you implement this function.
Best,
Marc
Did you get any error messages? Those might help to understand why the app crashed.
Sorry in fact it works after I restart R-Studio.
Thank you again for your advices and for your application which increases our exchanges between biologists and analysts!
Best,
Marc
Happy to hear you were able to make it work. Good job!