In R I need to add a new column based on a few other variables

I am new to R and am having trouble creating a new variable using conditions from already existing variables. I have a dataset that has a few columns: Name, Month, Binary for Gender, and Price. I want to create a new variable, Price2, that will:

  1. make the price charged 20 if [the month is 6-9(Jun-Sept) and Gender is 0]
  2. make the price charged 30 if [the month is 6-9(Jun-Sept) and Gender is 1]
  3. make the price charged 0 if [the month is 1-5(Jan-May) or month is 10-12(Oct-Dec] Thank you!


Read more here: https://stackoverflow.com/questions/68470667/in-r-i-need-to-add-a-new-column-based-on-a-few-other-variables

Content Attribution

This content was originally published by KiraLightYagami at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: