I am a newbie to R and seek help to calculate sums of selected column for each row. My simple data frame is as below.
data = data.frame(location = c(\"a\",\"b\"
Here is a quite simple solution using apply.
apply
output <- data.frame( x1 = apply(data[2:4], 1, sum) , x2 = apply(data[5:7], 1, sum) )
result:
output > x1 x2 > 1 14 13 > 2 66 18 > 3 8 12 > 4 100 24