Hi there

I'm wondering how to filter and summarise the following DF using a single line code into a new dataframe (DF1). In other words, how to filter different row ranges (separately) for each column nomenclature (group A and B) and returning the mean.for each sub group.

So far, thats what I have found:

DF1<-DF %>% Filter(between(VALUE, 1,3) %>% summarise(meanVALUE=mean(VALUE))

Nevertheless it will return the mean for the first sub group only (values 1,2,3). How to consider the remaining groups within the filter?

| GROUP | VALUE |

|A| |1|

|A| |2|

|A| |3|

|A| |4|

|A| |5|

|A| |6|

|B| |7|

|B| |8|

|B| |9|

|B| |10|

|B| |11|

|B| |12|

Any help is very appreciated.

Thanks!