Customize the variables shown in dropdown list

I am working on a SHINY app, and I am using a dropdown menu which comes with 100 different variables. I want to show only a subset of these. I could shorten the data.frame, but I need it to be this long for other reasons. Any ideas?

Thanks for your help.

this is what I have on server.R:

output$xvar <- renderUI(selectInput('xvar',label='I want to show only certain variables here', choices = names(df),selected = names(df)[1]))

I'm not clear, do you want to change the label, or the values that can be selected in the list?

The latter is done with the choices argument.

At the moment you set choices to be names(df); if you just want to allow the user to select a subet of values, then change the choices argument, e.g

label = "A label for the input widget", 
choices = [the allowable values]

If you want to change the label on the input widget, then you will need some similar logic to create the label value. For that you could use paste() or functionality from the glue package to create a label with the values from the data.

1 Like