PiperGordon
PiperGordon

Reputation: 1

Group_by, summarise reactivity not working

Reactivity is working everywhere else in my app, but when I try to create a summary statistic table the table returns the name of the variable selected instead of the summary statistic:

ui <- selectInput('summary_metric', 'Select Metric', choices = c('height', 'weight'))
      tableOuput('summary_table')

server <- function(input, output) {
      output$summary_table <- renderTable({ data %>% group_by(Age_Group) %>% 
                                                     summarise(min = min(input$summary_metric),
                                                               median = median(weight))})

Returns a table that reads:

Age_Group min median
18-29 weight 170
30-39 weight 180
40-49 weight 190

when 'weight' is selected in the UI and toggles to 'height' in the min column when 'height' is selected in the UI. So instead of calculating the minimum, it is just returning the variable name. Any thoughts as to what I'm missing?

Upvotes: 0

Views: 288

Answers (0)

Related Questions