I couldn't find a solution anywhere,
I have this selector with named variables:
library(shiny)
library(shinythemes)
#ui.r
ui <- fluidPage(
uiOutput('input')
)
#server.r
server = function(input, output) {
output$input <- renderUI({
variable1 <- 'dog'
variable2 <- 'cat'
variable3 <- 'mouse'
selectInput(inputId = 'something',
label = 'select animal',
choices = c(variable1 = 'animal1',
variable2= 'animal2',
variable3 = 'animal3'))
})
}
shinyApp(ui, server)
I want to see the result of each variable rather than the name of the variable. I mean I want to be able to select between dog
, cat
, or mouse
. But it has to remain a named choice since in later I will have to use those values as animal1
, animal2
or animal3
.
That's why this is NOT a solution for me, since it's not named. Even though it produces the selector that I want.
selectInput(inputId = 'something',
label = 'select animal',
choices = c(variable1,
variable2,
variable3 ))
I have tried several attempts like as.character()
or making it inside a vector/list but couldn't make this work.