# NOT RUN {
data(efc)
efc %>% row_sums(c82cop1:c90cop9)
library(dplyr)
row_sums(efc, contains("cop"))
dat <- data.frame(
c1 = c(1,2,NA,4),
c2 = c(NA,2,NA,5),
c3 = c(NA,4,NA,NA),
c4 = c(2,3,7,8),
c5 = c(1,7,5,3)
)
dat
row_means(dat, n = 4)
row_means(dat, c1:c4, n = 4)
# at least 40% non-missing
row_means(dat, c1:c4, n = .4)
# create sum-score of COPE-Index, and append to data
efc %>%
select(c82cop1:c90cop9) %>%
row_sums() %>%
add_columns(efc)
# }
Run the code above in your browser using DataLab