简体   繁体   中英

Creating Dynamic checkboxGroupInput in Shiny package in R

I need to create a group of check boxes using the checkBoxGroupInput from a data frame retrieved dynamically from the back end (Excel or database). I can retrieve the desired column vector from the data-frame and show it as a 'dynamic' drop-down using the following code snippet:

library(shiny)
library(ggtern)
library(scales)

setwd("~/R/data")
library(XLConnect)
df <- readWorksheetFromFile("ternary_diagram_all.xlsx",sheet=1,startRow = 1, endCol=7)


ui <- shinyUI(fluidPage(
  wellPanel(
     titlePanel("VGLab Ternary Diagrams"),
     selectInput('wellName', 'Select Well', unique(df$Well))
  ),

I want to turn the unique values of the Well column for the df data frame into a set of check boxes that are rendered on the client. I have looked up the documentation for the checkboxGroupInput, but do not know how to supply the list/vector for creating the check boxes.

Please advise. I am a shiny beginner.

Thanks.

Bharat

I imagine you saw this in the documentation:

checkboxGroupInput(inputId, label, choices, selected = NULL, inline = FALSE, width = NULL)

For the choices parameter, using c(unique(df$Well)) should do it. c() creates a vector of the unique values in the chosen "Well" column.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM