I am trying to create a list of radiobuttons consisting of the headers in an array selected by a drop down menu.
As you can see in this sample code - I think I need a reactive function to generate the list based on the selection. I know how to retrieve the names of the headers, but need help with turning this into a list that can be passed to the radioButtons() on the UI side. For instance, is using reactiveText() correct?
______________________________________________
library(shiny)
# Define UI for dataset viewer application
shinyUI(pageWithSidebar(
# Sidebar with controls to select a mineral group, with radiobutton list of minerals in that group generated in response
sidebarPanel(
selectInput("mineralgroup", "Choose a mineralgroup:",
choices = c("Carbonates", "Feldspars")),
radioButtons("min", "Mineral:",
("radiolist"))
)
))
__________________________________________________________
library(shiny)
carbonates <- read.csv("CARBONATES.csv")
feldspars <- read.csv("FELDSPARS.csv")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
datasetInput <- reactive(function() {
switch(input$mineralgroup,
"Carbonates" = Carbonates,
"Feldspars" = Feldspars)
})
# A reactive function creating list of radiobuttons based on "mineralgroup" choice
output$radiolist < reactiveText(function() {
list(names(datasetInput())
})
})