R/d2a.R

Defines functions d2a

Documented in d2a

d2a <- function(bd){
  if((inherits(bd, "Date"))){
    tmpfunc <-  function(x){
      if(!is.na(x) | !is.na(x!="") | !is.na(as.character(x)!="NA")){
        as.numeric(
          gsub("[A-Za-z]|\\s+", "",
               floor(diff.Date(  c(  (x)  , as.Date(Sys.Date()) ) )
                     / 365)
          )
        )
      }else{return(NA)}
    }
    tmpres1 <-unlist(
      lapply( as.Date( bd, format = "%m/%d/%Y" ), tmpfunc  )
    )
    return(tmpres1)
  }else{message("Please ensure argument bd is a Date class object")}
}

Try the ageg package in your browser

Any scripts or data that you put into this service are public.

ageg documentation built on Oct. 31, 2022, 5:06 p.m.