[R] Vectors of years, months, and days to dates?

Shin, Daehyok sdhyok at email.unc.edu
Mon Jun 7 17:16:10 CEST 2004


The interface for dates in R is a little confusing to me.
I want to create a vector of Date objects from vectors of years, months, and
days.
One solution I found is:

years <- c(1991, 1992)
months <- c(1, 10)
days <- c(1, 2)

dates <- as.Date(ISOdate(years, months, days))

But, in this solution the ISOdate function converts the vectors into
characters,
which can cause serious performance and memory loss
when the vectors of years, months, and days are huge.
I am quite sure there is much better solution for it. What is it?

Thanks.

Daehyok Shin




More information about the R-help mailing list