Create dynamic UI using R/Shiny where user input toggles parameter from a constant to a range

I'm new to Shiny and making an app where the output will ultimately be a plot of points produced using a function evaluated over a user-imposed range of variation in the x-axis parameter. There are 20 possible parameters from which the user can choose 1 to impose as x, but the rest of these parameters are also used by the function as single values. I want to make the app such that:

All of the 20 variables are visible in the app as single-value sliders

The user can change 1 of these single-value sliders at a time to a range slider by selecting the name of the parameter pertinent to the slider from a drop-down list

Only 1 slider at a time can be a range slider, meaning that a slider previously selected to produce a range of values should revert to some single default value when a different slider is selected to produce a range

So far I have succeeded in only producing one slider that can be manipulated using the drop-down list. In ui.R, I simple have

So I'm fairly stuck with this. In order to have the single-value default sliders, it seems like it would be necessary to write this into ui.R; however, that means they cannot be dynamic as ui.R is run only once when the app is launched. It may be necessary to use

There are different ways to create a dynamic UI with shiny. Here is one possible solution for your problem. The main idea is to use a reactive variable to store the the name of the selected variable. Only the selected variable in the selectInput will have a range slider and the remaining variables will have a single value sliders with a default value. An associated observer with the selectInput will change the name of the selected variable and the rangeUI will be rendered again.