1

I have a shiny app, for example

library(shiny)

ui <- fluidPage(
 checkboxGroupInput("checkboxname",
                   label = "name",
                   choices = list("Mary" = "Mary",
                                  "Tom" = "Tom",
                                  "John" = "John",
                                  "Kevin" = "Kevin",
                                  "Rebecca" = "Rebecca"),
                                  selected = "Mary"),
 plotOutput(outputId = "plot")
)

server <- function(input, output) {
 output$plot<- renderPlot({
  dt <- dt[name %in% input$checkboxname]
 })
}
shinyApp(ui, server)

I can filter the dataframe data according to the checkbox.

Now, I have other dataframe

x=data.frame(Name=c("Mary","Tom","John","Kevin","Rebecca","Tom","Kevin"),
         Grade=c("90","68","55","59","70","88","15"))

I want to change the name of the ui checkbox to the name from this x dataframe

so ui view like this

□Mary
□Tom
□John
□Kevin
□Rebecca
□Tom
□Kevin

But can't lose the original filtering function

And the dataframe data is different every time.

So, I don't know how to do it.

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
kolinunlt
  • 349
  • 1
  • 11

0 Answers0