Answers for "r conditionally replace values"

R
0

r change column based on condition

# If a condition is met in a specific column (column "b" is 0), 
# change the value in column "est". Here the value is replaced
# by the value for "a" in that same row where b == 0.

df$est[df$b == 0] <- df$a[df$b == 0]
Posted by: Guest on March-25-2020
0

r change column value conditionally

df <- within(df, est[b==0] <- (a[b==0]-5)/2.533)
Posted by: Guest on August-12-2020

Browse Popular Code Answers by Language