I am trying to create a new column that counts the amount of numbers that are grater than 5 across columns. for each number greater than 5 I would like to add 20 to a new column.
I am a beginner with R (For several years now :) and a loop approach is to intimidating for me. I would like to know if there is an easy tydivere option.
Example data set:
df <- data.frame(name = paste0("name", 1:7),
            X1 = c(-1:5),
            X2 = c(1:7),
            X3 = c(2:8),
            X4 = c(3:9),
            X5 = c(4:10),
            X6 = c(5:11))
DesiredOutcome <- c(0,20,40,60,80,100,100)
df <- cbind(df, DesiredOutcome)
df
I would be very grateful for any help and tips for how to approach something like this in the future.
 
     
    