myFrame$year<-years(strptime(x)) On Fri, Aug 13, 2010 at 12:36 PM, Dimitri Liakhovitski <dimitri.liakhovit...@gmail.com> wrote: > 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 > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.