vendredi 9 novembre 2018

Assistance with ifelse formula

I'm new to R in general and find that I get stuck on the syntax of ifelse a lot.

Here is an expression that I have written, it runs without error but doesn't seem to actually do anything:

AutoRenewals$LTA_year <- ifelse(AutoRenewals$Unity_LTA_Year == "2019" & AutoRenewals$LTA_year == NA,"2019",AutoRenewals$LTA_year)

Effectively what I want is to say that if a row(s) within the column of LTA_year is blank (NA) and the string value of 2019 is present in Unity_LTA_Year then I want LTA_Year column to show 2019, otherwise keep the original value of LTA_Year in place.

Aucun commentaire:

Enregistrer un commentaire