I understand we can write loop in server.R, but are we able to have loop in ui.R?
My need for loop in ui.R is this:
say if user selects certain input from pull-down menu with value=1, I want the width of my dygraph to be 12, otherwise with pull-down menu with value=0, I want the width of my dygraph to be 6.
If loop is not able to be achieved in ui.R, how can I achieve the above?
To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one for a shiny app
A rule of thumb for you is that ui.R is to position static UI elements. If you need dynamic parts, then you place containers for them with uiOutput and then give them renderUI definitions in your server code
in Shiny, it's not IF a user selects a value, it's coded for WHEN a user selects input. In normal coding you think linearly, but in Shiny, code is only ran WHEN it is needed