Hello,
I want to avoid declaring a loop. I am creating some dummies, and then, using summarise_at I would like just to sum the column "fact" for each vars I created. I tried something like this:
But I receive a message Error in is_fun_list(.funs) : objet 'fact_cal' introuvable
What am I doing wrong?
I mean, I plan to sum fact for s1,s2,...,s5 and grouping that operation by zone.
Is it possible? Is there an alternative?
Thanks for your time and interest.
datos %>% group_by(N,s1) %>% summarise(suma=sum(yield))
datos %>% group_by(N,s2) %>% summarise(suma=sum(yield))
datos %>% group_by(N,s3) %>% summarise(suma=sum(yield))
datos %>% group_by(N,s4) %>% summarise(suma=sum(yield))
datos %>% group_by(N,s5) %>% summarise(suma=sum(yield))
But I don't want to write four times the same code, and I don't want to declare a loop.
I hope my explanation is clear.
Thanks for your time, guys.
I should explain you don't want to summarize_at(vars(s1:s4)) because the column you want to summarize seems to be yield. It seems like instead you want to use s1:s4 as grouping variables, so it makes sense to pivot them so their values appear across rows and can be used in the group_by.