I have the following data.
df_a <- data.frame(id=c("John","Ben","Bill", "Eminem"),
amount=c("300", "500", "1000", "1200"),
issue_date=as.Date(c("2010-01-01","2011-01-01","2012-01-01", "2015-02-01")),
last_pymnt_date=as.Date(c("2013-02-01","2012-05-01","2014-01-01", "2018-02-01")),
months_passed=c(37,16,24,36),
term = c("36", "36", "36", "36"),
status=c("Fully Paid",
"Charged off",
"Does not meet the credit policy. Status:Charged Off",
"Does not meet the credit policy. Status:Fully Paid"),
stringsAsFactors = F)
library(DescTools)
df_a$maturity_dt <- AddMonths(df_a$issue_date, 36)
I want to make the last_pymnt_date
same as maturity_dt
if status
variable includes the expression "Fully Paid". If I run the following line it makes last_pymnt_date
variable some numbers.
df_a$last_pymnt_date <- ifelse(grepl("Fully Paid", df_a$status),
df_a$maturity_dt,
df_a$last_pymnt_date)
Any suggestion?
Thanks
Aucun commentaire:
Enregistrer un commentaire