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