So I have been doing some project in which I am using multiple if-else-if condition, the issue that I am facing is , whenever the first condition is met, the entire column is filled with that value itself, and it doesn't check further conditions . This the code snippet that I am using :
rdw_acct_dedup$PROCESS <- if (substr(rdw_acct_dedup$STATUS_CD,1,1) == 'S') { rdw_acct_dedup$PROCESS <- '01)SOLD' }else if(substr(rdw_acct_dedup$STATUS_CD,1,3) %in% c('894','895','910','994','D96','I25','I26','I27','Q34','V90','919','99F','99Q','D97','931','V22')) { rdw_acct_dedup$PROCESS <- '02)SIF-SETTLED' }else if(substr(rdw_acct_dedup$STATUS_CD,1,3) %in% c('899','I45','PDV','U10','U39','V63')) { rdw_acct_dedup$PROCESS <-'03)SIF-PENDING' }else if(substr(rdw_acct_dedup$STATUS_CD,1,1) == 'B') { rdw_acct_dedup$PROCESS <- '04)BANKRUPTCY'
}else if(substr(rdw_acct_dedup$STATUS_CD,1,1) == 'V') { rdw_acct_dedup$PROCESS <- '05)PRE-BANKRUPTCY' }else { rdw_acct_dedup$PROCESS <-'18)OTHER' }
So even if the first condition is met entire process columns gets filled with '01)SOLD'
Aucun commentaire:
Enregistrer un commentaire