So here is the problem: I want to use a for loop in my R code to summarize different columns.
As an example, here what it could look like:
all.columns<-c("column4","column5","column6","column7")
for (i in 1:4) {
df%>%
group_by(column3)%>%
summarise(Mean=mean(all.columns[i]),
Max=max(all.columns[i]))
}
Where df is a data frame, column3 could be a group by Year variable, and columns 5 to 7 the ones that I want to check repeatedly with the same code.
Do you know how to execute this with dplyr ? If you an alternative without dplyr, I'd like to hear about it.
I've tried to put the character name of the column, but it's not working...