G'day Isabella, On Tue, 10 Nov 2009 20:11:31 -0800 "Isabella Ghement" <isabe...@ghement.ca> wrote:
> I tried the solution you suggested and find that am having problems > getting R to extract the year from an object created by as.date(): Perhaps it would be best to first clarify what you really need. :) If you have to extract the year, why go via as.date? Why not just: R> strsplit("02-MAY-00", "-")[[1]][3] [1] "00" R> as.numeric(strsplit("02-MAY-00", "-")[[1]][3]) [1] 0 Or if you have a vector of character strings, each a date in that format: R> x <- c("02-MAY-00", "02-MAY-01") R> sapply(x, function(x) as.numeric(strsplit(x, "-")[[1]][3])) 02-MAY-00 02-MAY-01 0 1 HTH. Cheers, Berwin ========================== Full address ============================ Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Maths and Stats (M019) +61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009 e-mail: ber...@maths.uwa.edu.au Australia http://www.maths.uwa.edu.au/~berwin ______________________________________________ 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.