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

Gabor Grothendieck ggrothendieck at myway.com
Mon Jun 7 19:05:28 CEST 2004


Shin, Daehyok <sdhyok <at> email.unc.edu> writes:

> 
> Thanks, but, what I want is to convert three vectors of years, months, and
> days directly into POSIXlt or Date objects
> without creating character vectors.

I would probably just convert it to character using paste and from
that to Date as others have already suggested but if it is really
important to you for some reason not to use character variables
as intermediates try this:

require(chron)
z <- structure(julian(months, days, years), class="Date")

Note that when you print it out it may look like its character but
its not.    Try 

class(z)
is.character(z)
str(z)
dput(z)

to convince yourself.




More information about the R-help mailing list