How to create a new variable in a data.frame based on a condition? How to create a new variable in a data.frame based on a condition? r r