I am wondering if it is possible to compute a rowsums using a list, and also, filter the sum by a condition from a third variable.
I thought in something as
ghj : data frame list_g=("va1","va2",var3") ghj$jkj[ ghj$var4==10 ]=apply(ghj[,list_g],1,rowsums)
The syntax before clearly doesn't work.
As you see, I want to sum var1,var2,var3 only if var4==10.
It seems simple, but I can't figure it out.
Can you guide me?
Thanks for your time and consideration