[R] parsing DOB data

Peter Nelson pne|@on1 @end|ng |rom uc@c@edu
Wed Apr 15 20:31:11 CEST 2020

I have a data set (.csv) with date (eg date of birth) information stored as character vectors that I’m attempting to transform to POSIXct objects using the package lubridate (1.7.4). The problem that I’m trying to address is that my two digit years are invariably (?) parsed to 20xx. For example,

x <- c("45-12-03","01-06-24","64-9-15”)
[1] "2045-12-03" "2001-06-24" "2064-09-15”

These should be parsed as “1945-12-03” “2001-06-24” “1964-09-15”. 

I've tried to use parse_date_time()—based on the documentation it looks to me as though the argument cutoff_2000 should allow me to address this, but it’s unclear to me how to implement this. As an example, I’ve tried

parse_date_time(x, cutoff_2000 = 01)

but get the following error message (and similar for other similar attempts, including cutoff_2000 = 01L)

Error in parse_date_time(x, cutoff_2000 = 1) : 
  unused argument (cutoff_2000 = 1)

Thanks for your help!

Peter Nelson, PhD
Institute of Marine Sciences
University of California, Santa Cruz
Center for Ocean Health, Long Marine Lab
115 McAllistair Way
Santa Cruz, CA, 95076, USA

	[[alternative HTML version deleted]]

More information about the R-help mailing list