I'm not familiar with age_calc, but this is how I would calculate an age, or the exact length of a time span. This is the same as what I posted above, but this shows how to calculate the age.
# packages
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.1.2
#> Warning: package 'tibble' was built under R version 4.1.2
#> Warning: package 'readr' was built under R version 4.1.2
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
# the data frame
my_data <- tribble(
~birth_date,
01011999,
01021998,
02011997,
03041996
)
# convert from number to date
my_converted_data <- my_data %>%
mutate(birth_date_as_date = dmy(birth_date), # use the lubridate::dmy function
today_date = today()) %>% # create variable for today
mutate(age = time_length(x = difftime(today_date, # calculate interval between
birth_date_as_date),
unit = "years"))
# view
my_converted_data
#> # A tibble: 4 x 4
#> birth_date birth_date_as_date today_date age
#> <dbl> <date> <date> <dbl>
#> 1 1011999 1999-01-01 2021-12-30 23.0
#> 2 1021998 1998-02-01 2021-12-30 23.9
#> 3 2011997 1997-01-02 2021-12-30 25.0
#> 4 3041996 1996-04-03 2021-12-30 25.7
Created on 2021-12-30 by the reprex package (v2.0.1)