Hi,
i have a data with students test scores. I have to track the progress they make from test 1 to 2. I group it according to class, test and summarise the average. But I need only those observations which are below average. For example in class A, only those students which are below average in that class must be shown in the new data frame "dat_mod". Similarly for class B. But it gives me an error message. How can I resolve this?
data<-tibble::tribble(
~student, ~class, ~test, ~score,
"Nithin", "A", 1L, 32L,
"Gandhi", "B", 1L, 35L,
"Nehru", "A", 1L, 45L,
"Patel", "B", 1L, 27L,
"Rajaji", "A", 1L, 24L,
"Azad", "B", 1L, 36L,
"Nithin", "A", 2L, 40L,
"Gandhi", "B", 2L, 28L,
"Nehru", "A", 2L, 27L,
"Patel", "B", 2L, 55L,
"Rajaji", "A", 2L, 49L,
"Azad", "B", 2L, 56L
)
dat_mod<-data %>%
group_by(class,test) %>%
summarise(avg=mean(score)) %>%
filter(avg<mean(score))
#> Error in data %>% group_by(class, test) %>% summarise(avg = mean(score)) %>% : could not find function "%>%"
<sup>Created on 2022-10-15 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)</sup>