> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Fang (Betty) Yang
> Sent: Friday, October 23, 2009 11:06 AM
> To: R-help at r-project.org
> Subject: [R] extract day or month as in Splus
>
> Dear all,
>
>
>
> I am writing to ask for help to find R code to do the same
> thing as the
> following Splus code:
>
>
>
> dates <- c("02/27/1992", "02/27/1992",
"01/14/1992", "02/28/1992",
> "02/01/1992")
>
> timeDate(as.character(dates),in.format="%m/%d/%Y","%a")
>
> [1] Thu Thu Tue Fri Sat
You can use the POSIXct class to store the dates (instead
of the S+ timeDate class) and strftime() to format the output
(instead of attaching a default output format to the timeDate
object):
> strftime(as.POSIXct(dates, format="%m/%d/%Y"),
format="%a")
[1] "Thu" "Thu" "Tue" "Fri"
"Sat"
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
>
>
>
> Could anyone give me some R codes to get the same results as
> above(extract
> days from dates), please?
>
>
>
> Thanks in advance!
>
>
>
> Betty
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>