Shiny's serverside doesnt recognise my UI's input

Hey guys.
Lets say i have a dataframe that consists 3 categorical variables,

data = data.frame(
score=sample(rnorm(100),100,T),
cat_1=sample(c(T,F),100,T),
cat_2=sample(c("big","med","small"),100,T),
cat_3=sample(c("red","green","blue","orange"),100,T)
)

Now, instead of coding the right shinycode in the UI and then just use in the server this:

data %>% group_by(input$grouping) %>%s
ummarise(mean=mean(score))

It doesnt recognise the 'input$grouping' and instead i use tons of IF statements:

if(input$grouping=="cat_1"){
data %>% group_by(cat_1) %>%s
ummarise(mean=mean(score)) }
else { if(....){--}
}.

Now, my data (in my real shinyapp) is coded within a reactive wrapper, so I'm really struggling to understand what I'm doing wrong.
I also tried to type in the UI side choice=names(data) but this also doesn't work

Can you check on this?

data = data.frame(
  score=sample(rnorm(100),100,T),
  cat_1=sample(c(T,F),100,T),
  cat_2=sample(c("big","med","small"),100,T),
  cat_3=sample(c("red","green","blue","orange"),100,T)
)

library("dplyr")
data %>% group_by(cat_1) %>%  # I group by cat_1
summarise(mean = mean(score))
#> # A tibble: 2 × 2
#>   cat_1   mean
#>   <lgl>  <dbl>
#> 1 FALSE -0.154
#> 2 TRUE  -0.196

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.