[R] transforming dates into years
Dimitri Liakhovitski
dimitri.liakhovitski at gmail.com
Fri Aug 13 21:36:21 CEST 2010
Hello!
If I have in my data frame MyFrame a variable saved as a Date and want
to translate it into years, I currently do it like this using "zoo":
library(zoo)
as.year <- function(x) as.numeric(floor(as.yearmon(x)))
myFrame$year<-as.year(myFrame$date)
Is there a function that would do it directly - like "as.yearmon" -
but for years?
Thank you!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
More information about the R-help
mailing list