I have a data frame like this (with more vars)
tb = data.frame(ID=c("a","b","c"),V1=c(TRUE,FALSE,TRUE),
V2=c(FALSE,FALSE,TRUE),V3=c(TRUE,TRUE,FALSE) )
tb
ID V1 V2 V3
1 a TRUE FALSE TRUE
2 b FALSE FALSE TRUE
3 c TRUE TRUE FALSE
I need to add a fourth variable with the sum of true values by row like this but conserving all the other vars
tb %>%
select(V1:V3) %>%
mutate(out = rowSums(.))
V1 V2 V3 out
1 TRUE FALSE TRUE 2
2 FALSE FALSE TRUE 1
3 TRUE TRUE FALSE 2