I need help in one task. I have dataframe:
df <- data.frame(
UserGroup = c("UserGroup1", "UserGroup2", "UserGroup2", "UserGroup3", "UserGroup3", "UserGroup3", NA, NA, NA, NA),
User = c("User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8", "User9", "User10")
)
I would like to get version of selectInput like on the picture below.
I found the code:
selectInput("state", "Choose a state:",
list(
`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")
)
)
It is easy to do it manually, but the problem is that df is a data frame come from database and it can contain random number of groups and users. Does anyone have idea how to write code of selectInput or how to prepare data before to get expected effect automatically?