1

In my R shiny app I have a sliderInput:

sliderInput("number","Specify number :",min   = 1,max   = 10,value = 2,step  = 1)

I want to give some more inputs. The number of these inputs should be equal to the value of sliderInput (for each number less or equal to the sliderInput there should be another input option or a text message). This results in a number of conditionalPanels. Of course, I can define 10 different conditionalPanels, but I am looking for a loop or something. I tried lapply:

lapply(1:10,function(i){condition='number>=i',helptext('test-should depend on i')})

Unfortunately, this doesn't work. How can I define the condition depending on the sliderinput?

R_FF92
  • 552
  • 1
  • 5
  • 19
  • If `input$number` is 3, then we want 3 more textInput to show up? – zx8754 Jul 21 '16 at 11:44
  • 1
    Yeah correct. TextInput was just an example, I want to have numericInputs, but I think this doens't change the question – R_FF92 Jul 21 '16 at 11:45
  • 1
    Is [this](http://stackoverflow.com/questions/19130455) not what you need? (I didn't test the solutions.) – zx8754 Jul 21 '16 at 11:49
  • That is great yes! I solved the problem :) I put the other inputs in the server.R part as a render object and then it worked by calling it with output. Actually, I don't understand why my approach with lapply in UI.R doesn't work. But at least now I know how to do it. Thank you! – R_FF92 Jul 21 '16 at 12:25
  • 3
    Possible duplicate of [Create dynamic number of input elements with R/Shiny](http://stackoverflow.com/questions/19130455/create-dynamic-number-of-input-elements-with-r-shiny) – zx8754 Jul 21 '16 at 12:35

0 Answers0