[R] Vectors of years, months, and days to dates?
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Jun 7 18:56:57 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.
Well, if you insist:
x <- as.POSIXlt(structure(rep(0,2),class="POSIXct"))
x$year <- years-1900
x$mon <- months-1
x$mday <- days
as.Date(as.POSIXct(x))
This is definitely not kosher programming, and I doubt that it is the
least bit faster than the other solutions, but there's no character
vectors in there...
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list