Re: [R] Using split() several times in a row?

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Sat 31 Mar 2007 - 19:22:05 GMT

>>>>> "SteT" == Stephen Tucker <brown_emu@yahoo.com>
>>>>> on Fri, 30 Mar 2007 18:41:39 -0700 (PDT) writes:

  [..]

    SteT> For dates, I usually store them as "POSIXct" classes
    SteT> in data frames, but according to Gabor Grothendieck
    SteT> and Thomas Petzoldt's R Help Desk article
    SteT> <http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf>,
    SteT> I should probably be using "chron" date and times...

I don't think you should (and I doubt Gabor and Thomas would recommend this in every case):

POSIXct (and 'POSIXlt', 'POSIXt' & 'Date') are part of standard R, and whereas they may seem not as convenient in all cases as "chron" etc, I'd rather recommed to stick to them in such a case.

    SteT> Nonetheless, POSIXct casses are what I know so I can
    SteT> show you that to get the month out of your column
    SteT> (replace "8.29.97" with your variable), you can do the
    SteT> following:

    SteT> month = format(strptime("8.29.97",format="%m.%d.%y"),format="%m")

    SteT> Or,
    SteT> month = as.data.frame(strsplit("8.29.97","\\."))[1,]

  [......etc..very....useful..advice............]



R-help@stat.math.ethz.ch 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. Received on Sun Apr 01 05:26:52 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 31 Mar 2007 - 22:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.