Looking for a way to aggregate rows with different functions applying to different columns:
ID<-c('A','A','A','B','C','D','D','E','E','E')
branch<-c('a','b','c','a','a','a','b','a','b','c')
w <-sample (1:100, 10)
x <-sample (1:100, 10)
y <-sample (1:100, 10)
z <-sample (1:100, 10)
tib<-tibble(ID,branch,w,x,y,z)
I want to group by ID and use something like aggregate for each row with different branches of the same ID. I want the columns to aggregate differently from each other:
The result should be a single row per ID where rows have been aggregated by:
w -> sum
x -> mean
y -> mean
z -> sum
Is that possible please?