r change column value conditionally code example Example: r change column value conditionally df <- within(df, est[b==0] <- (a[b==0]-5)/2.533)