The following problem is abstracted from a webapp I am currently working on. In the actual version, the choices for the selectInput are imported and change based on previous user Input (thats why I am using renderUI).
The problem is the following: The input box does not show a default value (it actually does not have a value, as I get error messages from the calculations based on the input, at default).
I'd like to add to @ginberg suggestion. It is indeed a good idea to keep the values unique and even sort them for the user to use the selection input with the most ease.
I do suggest however that you use the updateSelectInput statement instead of creating a renderUI function. It will make your code cleaner and more intuitive. Here is my example:
Note that I created am empty selectInput in the UI, but I use the corresponding updateSelectInput at server level to assign the correct values. Every UI input has its corresponding update function in case you like to update it at server level.
You need to add a session statement to your server function in order to work with updateSelectInput (don't worry too much about it, it just ensures Shiny knows which UI elements to render or update for which user)
You can set any desired value as the default value of an input by just assigning a value of the choices to the selected argument