r mean by group keeping variable code example
Example: dplyr group by intervals of 3
d %>% mutate( ints = cut(v1 ,breaks = 11)) %>%
group_by(ints) %>%
summarise( mean.v2 = mean(v2) , mean.v3 = mean(v3) )
d %>% mutate( ints = cut(v1 ,breaks = 11)) %>%
group_by(ints) %>%
summarise( mean.v2 = mean(v2) , mean.v3 = mean(v3) )