[r] Replace a value in a data frame based on a conditional (`if`) statement