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:
data=data %>% mutate(s1=if_else(clasifier==1,1,0),s2=if_else(clasifier==21,1,0),
s3=if_else(clasifier %in% 3:4,1,0),s4=if_else(clasifier %in% 5:6,1,0),s5=if_else(clasifier==7,1,0))
data %>% group_by(zone) %>% summarise_at(vars(s1:s5),sum(fact,na.rm=TRUE))
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.