Let's say that I have the following dataframe:
df <- data.frame(a=c(1,2,3,3,1), b=(c(1,9,1,2,3)),
c=c(1,2,3,3,9), d=(c(1,2,3,9,1)))
df[,1:4][df[,1:4]==9]<-3
df$sum <- c(4,9,10,11,8)
One option would be to replace
elements having values greater than or equal to 9 with 3 and get the rowSums
df$Sum <- rowSums(replace(df[1:4], df[1:4] >= 9, 3))
df$Sum
#[1] 4 9 10 11 8