creating and adding a new variable into a data frame by using an if statement

Please remove the verbatim assignment question from your post as it violates the community's homework policy:

What have you tried so far? Are you stuck on a particular task? We can give advice if you ask a specific question.