So I have some data that looks like this:
lat long group
40.75482559 -73.84514618 One
40.75759888 -73.84442902 Two
40.75468826 -73.84588623 One
40.82676315 -73.92416382 One
40.82736206 -73.92511749 Two
40.787167 -73.977325 Two
40.82994843 -73.92955017 Two
40.75819016 -73.844841 One
40.82663345 -73.92651367 Two
And I'm trying to dynamically display latlong points by their group.
In my ui.R code, I have:
checkboxGroupInput("group",
label = h3("Checkbox group"),
choices = list('One' = 1,
'Two' = 2)
))
In my server.R code, I have:
filteredData <- reactive({
df <- randomtaxi[randomtaxi$group == "One",]
return(df)
})
Which works fine. But the moment I try to add something like
df <- randomtaxi[randomtaxi$group == input$group,]
It crashes. I've also tried things like:
if (input$team == 1){
df <- filter(df, group == "One")
and
if (input$team == "One"){
df <- filter(df, group == "One")
But I can't seem to get it to work. How can I dynamically subset data using CheckboxGroupInput in RShiny?