I want to summarize my dataset by certain columns (Client, Year, LoS, and Country)
But I don't get this when I use group_by, and then summarize, I get only partial summarization...
What am I doing wrong?
I want to summarize my dataset by certain columns (Client, Year, LoS, and Country)
But I don't get this when I use group_by, and then summarize, I get only partial summarization...
What am I doing wrong?
I think this should do the trick
library(plyr)
ddply(data, .(Client, Year, LoS, Country), function(x){colSums(x[,5:6]))}
Something like this? Please be more clear on what you need.
data %>%
group_by(Client, Year, LoS, Country) %>%
summarise_all("mean", na.rm = TRUE)