Vary the choices in selectinput based on other conditions in shiny R -


I have a selection input panel in shiny. I still work with select values ​​of options in selectInput.

Now I am at a point where I want to change these options based on some other situations in bright u.

Example:

Ui.R

  shinyUI (fluidage (Fluidro (column (3, Velpainel (H4) ("Data upload"), fileInput ('File1', h5 ('Choose your model data'), accept = c ('text / csv', 'text / comma-separated-values, text / plain', '.' OUT '), fileInput (' file2 ', H5 (' select your observation data '), accept = c (' text / csv ',' text / comma-separated values, text / plain ',' .xlsx ' )), VelPanel (uiOutput ("check"))))  

server.r

  shinyServer (function (Input, Output) {Check Output $ & amp;; - Render UI ({selectInput (" Check ", label = H4 (" dataset selection "), option = c (" model "= 1," observation "= 2," both "= 3), selected = 1, multiple = f)}) a & lt ; - Reactive ({fileinput1 & lt; - input $ file1 if (i s.null (fileinput1)) return (zero) read.table (fileinput1 $ datapath, header = true, col.names = c ("Ei", " "DIC", "Doc", "Doctor", "DIN", "D.C.", "M", "Hours", "Nphy", "Cphy", "Chlphy", "Nhet", "Cheat", "Ndet", "Cdet" "On", "dccho", "TEPC", "Ncocco", "Ccocco", "CHLcocco", "PICcocco", "equivalent", "temporary", "year", "co2atm", "U10", "dicfl "," Co2ppm "," co2mol "," pH "))}) #upload overview data b & lt; - Reactive ({fileinput2 & lt; - Input $ 2 if (is.null (fileinput2)) Return (zero) #xlfile & lt; - list.files (pattern = ".xlsx") xlfile & lt; - fileinput2 [ 1] West Bengal & lt; - loadWorkbook (xl_file) sheet_ct & lt; - West Bengal getNumberOfSheets () b & lt; - rbindlist (pblapply (1: sheet_ct, function (x) {race   

Now I want to make choices in select input dynamic file input based on.

I have tried to fix some problems in the server. R file. Note that I have followed the following algorithm

  1. If file1 is uploaded first, then the option is "model"
  2. If file2 is uploaded later, then the option " Model "," observation ", if both files are uploaded before," observation "
  3. if file 1 is uploaded then option" model "," observation "," both "library ( Bright) Library (XLSX)

      shinyServer (function (input, output) {a & lt; - copy Active ({fileinput1 & lt; - input $ file1 if (is.null (fileinput1)) return (zero) # read.table (fileinput1 $ datapath, header = true, col.names = c ("Ei", "Mi "," D "," Dix "," Doctor "," Dick "," Dixie "," Nphy "," Cphy "," Chlphy "," Nhet "," Cheat "," Ndet "," Cdet " "Dccho", "dccho", "TEPC", "Ncocco", "Ccocco", "CHLcocco", "PICcocco", "equivalent", "temporary", "year", "co2atm", "U10", "dicfl" "Co2ppm", "co2mol", "pH")) # Please change this part back to your code because I'm not based on the column names above your file read.ta ble (fileinput1 $ datapath, header = TRUE)} # Upload overview data b & lt; - Reactive ({fileinput2 & lt; - Input $ 2 if (is.null (fileinput2)) Return (zero) #xlfile & lt; - List files (pattern = ".xlsx") xlfile & lt; - fileinput2 $ Datapath west Bengal l loadWorkbook (xlfile) sheet_ct & lt; - West Bengal getNumberOfSheets () b & lt; - rbind (list (lapply (1: sheet_ct, function (x) {Res & lt; - read.xlsx (Xlfile, x)})) b & lt; -b [-c (1),] print (b)}) millmodel & lt; - Reactive ({Is.null (a ()) & amp;; Is.null (b ()) {c ("model", "observation", "both")) and if (! {"Model"} and if (! Tap (b ())} {"observation"}} checkout output $ <--RenderUI ({selectInput ("check", label = H4 ("Dataset selection"), option = as.list (getModel ()), multiple = f)})})  

Comments