using reactive data in flexdashboard to get specific data

40 Views Asked by At

I'm creating a dashboard using flexdashboard and shiny in R. I'm trying to make it so that after clicking the name you want to get data for from dropdown list, you will also need to select a date from another dropdown list for that person. I can create an initial dropdown list using

library(flexdashboard)
library(tidyverse)
library(ggplot2)
library(shiny)

Sidebar {.sidebar}
-------------------------------------
selectInput(inputId = "player_name", label = "Select Player Name", choices = athlete_data$athlete)

I've then tried to make the "Dates" dropdown based on the name you select by adding

Sidebar {.sidebar}
-------------------------------------

selectInput(inputId = "player_name", label = "Select Player Name", choices = athlete_data$athlete)

single_athlete_dates <- reactive({
  athlete_data %>%
    filter(athlete == input$player_name)
})

selectInput(inputId = "dates", label = "Select Test Date", choices = single_athlete_dates()$date)

But i just get this warning

Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. • You tried to do something that can only be done from inside a reactive consumer.

any ideas?

p.s. is there a way to export my dashboard as a pdf or be able to send the resullting dashboard out as an email link or something? sorry im used to Power BI and now starting to transitioning over :)

1

There are 1 best solutions below

0
bischrob On

What you are looking for is uiOutput. Something like this:

# ui
uiOutput("datesUI")

# server
output$datesUI = renderUI({
    selectInput(inputId = "dates", label = "Select Test Date", choices = single_athlete_dates()$date)
})