dimanche 24 janvier 2016

error: ifelse() function in R

I'm running this:

y2$term_date_5yr = ifelse(y2$events_char_5yr == "Current", 500+y2$Time, 

ifelse(y2$events_char_5yr == "Default", 
                            y2$dlnq_date, 100*y2$prepayyear+y2$prepaymonth))

And my data look like this:

events_char_5yr  Time dlnq_date prepayyear prepaymonth
Default  200301     200405     NA    NA
Prepay   200105     NA       2004    6
Current  200012     NA         NA    NA  NA     

All columns except the first one are numerical (i.e. numbers). The code ran through fine. But when I look at the results, I saw that all "Default" cases are showing NA for this new variable "term_date_5yr" I'm creating. What did I do wrong?

Aucun commentaire:

Enregistrer un commentaire