Dynamic dataframe in flexdashboard

Hi,

I'm working for the first time with flex dashboard and shiny. I want to apply a date filter to the data set based upon two variables. However, I keep running into Error: object of type 'closure' is not subsettable.

How can I make a reactive data frame based upon the filter? I checked out online posts, but I cannot seem to get it working. Further on, I want to aggregate data into new tables for further graphs, as the actual data set has many more variables for reporting.

I made the following reprex of the code of a Rmarkdown file:

rating <- c(2, 3, 5, 4, 1, 5, 3, 1, 4)
gender<- c("m"," m", "f", "m", "f", "x", "m", "f", "x")
type <- c("restaurant", "hotel", "restaurant", "hotel", "restaurant", "hotel", "restaurant", "hotel", "hotel")
date <- c("2021-05-14", "2021-05-07", "2021-05-06", "2021-04-11",
"2021-01-07", "2021-12-06", "2021-04-11", "2021-01-07", "2021-12-06")
data <- data.frame(rating, date, type, gender)

all_types_1 <- list("All types" = "none")
all_types_2 <- as.list(unique(data$type))
all_types_3 <- append(all_types_1, all_types_2)

selectInput("type", label = tags$b("Type"), 
    choices = all_types_3, 
    selected = "All queues")

dateRangeInput('dateRange',
      label = tags$b('Date range'),
      start = min(data$date), end = max(data$date),
      min = min(data$date), max = max(data$date),
      separator = " - ", format = "yyyy-mm-dd",
      startview = 'year', language = 'en', weekstart = 1
    )

data_2 <- reactive({
     data_2<-data[date >= input$dateRange[1], date <= input$dateRange[2], ]
     })

rate <- mean(data_2$rating)
gauge(rate, min = 1, max = 5, gaugeSectors(
  success = c(4.5, 5), warning = c(2.5, 4.49), danger = c(0, 2.49)
))

Any help would be appreciated!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.