I can't make any promises since we don't have a sample of your data, but I would guess that you have some missing values in your dob object, which is causing the error. I'm put together the following example
library(eeptools)
#> Warning: package 'eeptools' was built under R version 4.0.5
#> Loading required package: ggplot2
dob <- rep(Sys.Date()-(365*10), 3)
age_calc(dob, units = "years")
#> [1] 9.991781 9.991781 9.991781
# Now let's force one of those to be NA
dob[2] <- NA
age_calc(dob, units = "years")
#> Error in if (any(enddate < dob)) {: missing value where TRUE/FALSE needed
# Created on 2021-08-26 by the reprex package (v2.0.1)
It seems that age_calc isn't well suited to handling missing values. I would probably approach this with the following function as a wrapper around age_calc to get the desired result:
age_calc_miss <- function(dob, enddate = Sys.Date(), units = "months", precise = TRUE){
retval <- rep(NA_real_, length(dob))
miss <- is.na(dob)
retval[!miss] <- eeptools::age_calc(dob = dob[!miss],
enddate = enddate,
units = units,
precise = precise)
retval
}
dob <- rep(Sys.Date()-(365*10), 3)
dob[2] <- NA
age_calc_miss(dob, units = "years")
#> [1] 9.991781 NA 9.991781
Created on 2021-08-26 by the reprex package (v2.0.1)