0

I'm experienced with R but new to designing R shiny apps. How can I hide inputs based on branching logic?

For example, suppose there is a name input accepting "Bob", "Rob", and "James" and a DOB input comprised of "Bob_DOB", "Rob_DOB", and "James_DOB". I want my R shiny app to show a name input field, allow for user input, and then show only the corresponding DOB field to allow for the input of a DOB.

SpencerK
  • 3
  • 3
  • Please provide sample code what you have tried so far – Pork Chop Jun 15 '20 at 15:38
  • [This post](https://stackoverflow.com/questions/62376985/need-to-build-dependency-for-3-insertui-fields-coming-from-excel-sheet-in-rshiny/62382998#62382998) demonstrates one posible technique for dynamically showing and hiding input widgets in response to changes in another widget. I'm surprised that you need to show different input controls to record the same data item for different data records. But I'll assume that you've kindly supplied us with a use case so simple that the reason for this is obscured... – Limey Jun 15 '20 at 16:31
  • I usually find `renderUI` to be most useful when I want one input to depend on the value of another one, since you can use standard R commands to define the conditions that will determine the state of you input (in your case the DOB field). Alternatively you can use a `conditionalPanel` but that requires a JavaScript expression. This [link](https://shiny.rstudio.com/articles/dynamic-ui.html) should help. As @Pork Chop suggested, a minimum working example of your code would make it easier for others to help you. – patalt Jun 15 '20 at 16:47

0 Answers0