Homework help in R studio needed

Hi KingKhan248, welcome to RStudio Community.

Please read our Homework Policy and modify your post to comply with the guidelines.

As for your question, there is a hint provided in the third line. R has a function called ifelse(). Try using that. You can type ?ifelse in the console to check the function documentation (it also has examples).