lundi 3 juin 2019

If Else statement for new variable

I want to code the months into quarter and use one line of code for it. I am coding fiscal quarters. So months 4-6 is 1, months 7-9 is Quarter 2, months 10-12 is Quarter 3 and months 1-3 is Quarter 4

I have tried the ifelse statement but it gives me an error for the first part

ACLED$quarter<- ifelse(ACLED$month==4 & ACLED$month==5 & ACLED$month==6, 1)

Error in ifelse(ACLED$month == 4 & ACLED$month == 5 & ACLED$month == 6,  : 
  argument "no" is missing, with no default

How do I solve this?

Aucun commentaire:

Enregistrer un commentaire