jeudi 8 janvier 2015

If Else Statement and Removing NA's

I am using an ifelse statement to tell the program to categorize months into their respective quarters. For example January-March (I), April-June (II).....etc. I use the following ifelse statement:



eight$quarter<-ifelse(eight$month=="01", eight$quarter=="I", 0)


Whenever there is an "01" value in the column titled, "month" for some reason the "quarter" column comes up with the value on NA. Everything else is fine, as values 02-12 come up zero. I am curious as to where my coding has gone wrong so I may remove the NA's and replace them with the respective quarter number.


Aucun commentaire:

Enregistrer un commentaire