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\"
My sense would be to use dply:
require(dply)
data %>% mutate(v2v4 = rowSums(.[2:4])) %>% mutate(v4v6 = rowSums(.[5:7])) %>% select(-(location:v6))
result:
> newDf <- data %>% mutate(v2v4 = rowSums(.[2:4])) %>% mutate(v4v6 = rowSums(.[5:7])) %>% select(-(location:v6))
> newDf
v2v4 v4v6
1 14 13
2 66 18
3 8 12
4 100 24