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]))
Wrap the subset into a reactive and just render that:
library(shiny)
ui <- fluidPage(
uiOutput("xvar")
)
df <- 1:100
server <- function(input, output, session) {
dfsubset <- reactive({
df[1:10]
})
output$xvar <- renderUI(selectInput('xvar',label='I want to show only certain variables here',
choices = dfsubset(),selected = dfsubset()))
}
shinyApp(ui,server)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.