I have a dataframe:
dat <- data.frame(X1 = c(0, NA, NA),
X2 = c(1, NA, NA),
X3 = c(1, NA, NA),
X4 = c(1, 5, 8),
X5 = c(2, 6, 4),
X6 = c(3, 3, 3))
I want to sum across the rows X4, X5 and X6 to get a total score. However, any number that is above 6 in those columns will have to be counted as a 7 before being added with the other columns to get a total score.
What is a concise way to go about doing this?
Thank you!