Highto convert strings into date use the:"? strptime" command, it
converts data into POSIXlt classthis class provides direct access to some
details of your date time information,
likea<-strptime("07/07/1992",format="%d/%m/%Y")"a$mon+1"
gives you the month (+1 because POSIXlt uses 0-11 for months
counts)"a$year" gives you the yearMarcel Sandow----- Ursprüngliche
Nachricht -----Von: Mary Royerr Datum: Dienstag, Oktober 9, 2007 3:39 pmBetreff:
[R] extract year or month from dateAn: r-help@r-project.org> Hi,> > I
am having trouble extracting just the year or the month or the > day from
a> date such as 5/7/2007 which is May 7th 2007. Is there any particular>
function to extract just the year from this format?> > When I am reading
this data from a text file it is reading it > correctly in> the same
format but does not acknowlede it as date but as a > factor. If I try>
as.date(5/7/2007) then it is converting it to 1Jan1960. Weird it > is.
Any> help on that front?> > Any help is greatly appreciated.> >
[[alternative HTML version deleted]]> >
______________________________________________> 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.>
______________________________________________________________________________
Marcel Sandow
Leibniz Institute of Marine Sciences - IFM-Geomar
Experimental Ecology: Foodwebs
Düsternbrooker Weg 20
24105 Kiel
Germany
Fon: +49-431-600-4404
Fax: +49-431-600-1515
Homepage: http://www.ifm-geomar.de
E-mail: msandow@ifm-geomar.de
[[alternative HTML version deleted]]