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:
- make the price charged 20 if [the month is 6-9(Jun-Sept) and Gender is 0]
- make the price charged 30 if [the month is 6-9(Jun-Sept) and Gender is 1]
- make the price charged 0 if [the month is 1-5(Jan-May) or month is 10-12(Oct-Dec] Thank you!
This is what I am coding right now but I do not even see the new column Price2.
mutate(Price2=case_when(Mon>=6 | Mon<10 & Gender!=1 ~ 20,
Mon>=6 | Mon<10 & Gender==1 ~ 30,