Hi all- Trying to convert age in years to months & days, accounting for some 'NA' values in respective columns (age in months only recorded for children < 5 years): The following isn't working for me, for some reason.
##Creating an age in years variable for children whose age in months was recorded (preferred; more precise);
df_temp<-df_temp %>%
mutate(age_years_correct = ifelse(floor(age_months/12)!=age_years,
floor(age_months/12),
age_years))
## Trying to substitute age in years recorded for those without an age_years_correct value.
df_temp<-df_temp %>%
mutate(age_years_correct = ifelse(age_years_correct==NA,
age_years,
age_years_correct))
#age in months for those missing
is.na(df_temp$age_months)
#GHHelp also not working.
df_temp<-df_temp %>%
mutate(age_months_correct = ifelse(age_months==NA,
age_years*12,
age_months))
#Creating an age in days based on age_months
df_temp$age_days<-df_temp$age_months * (365.25 / 12)