I wish to RowSums the total number of columns (in this case years of education) but only if a value (the age of respondents) is greater than a certain number (>=16). The number of columns is greater than the example (up to 13 for age and education) so I wish to find an efficient way to achieve the RowSums without relying on a column by column sum and by keeping the structure of the proposed dataframe as it is since I wish to cbind more columns afterwards.
What is the best way to get from this dataframe [...]
Age1 <- c(21,31,51,72)
Age2 <- c(22,33,34,54)
Age3 <- c(7,11,10,21)
Edu1 <- c(5,10,10,10)
Edu2 <- c(5,10,5,5)
Edu3 <- c(2,5,4,10)
df <- data.frame(Age1, Age2, Age3, Edu1, Edu2, Edu3)
[...] to TotEdu results?