I have some data:
set.seed(565)
df <- data.frame(rs1 = rnorm(100, mean = 50, sd = 3), rs2 = rnorm(100, mean = 4, sd = 0.2), rs3 = rnorm(100, mean = 15, sd = 1),
rs4 = rnorm(100, mean = 2, sd = 0.04))
I want to replace any number less than 3 in this dataframe with NA, but make sure that the number that was replaced is added to the variable with the highest number in that row (so the row total does not change). E.G. for row 1, which looks like:
50.92756 4.033628 14.36690 1.999160
after the command should look like:
52.92672 4.033628 14.36690 NA