Re: [R] Extracting day of month from Date objects

From: Kang Min <ngokangmin_at_gmail.com>
Date: Tue, 24 May 2011 10:42:24 -0700 (PDT)

Thanks Phil, chron is good.

On May 25, 1:34 am, Phil Spector <spec..._at_stat.berkeley.edu> wrote:
> I've always found the chron library to be useful for
> tasks like this:
>
> > x <- round(runif(10)*100000, digits=0)
> > y <- as.Date(x, origin="1970-01-01")
> > library(chron)
> > days(y)
>
>   [1] 7  25 26 25 10 24 1  31 12 8
> 31 Levels: 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < ... < 31
>
> Notice that it returns the days as factors.
>
>                                         - Phil Spector
>                                          Statistical Computing Facility
>                                          Department of Statistics
>                                          UC Berkeley
>
> On May 24, 2011, at 10:19 AM, Kang Min wrote:
>
> > I have another question -
>
> > I'd like to extract dates from a vector of yyyy-mm-dd, so I just want
> > the dd.
>
> > x <- round(runif(10)*100000, digits=0)
> > y <- as.Date(x, origin="1970-01-01")
>
> > I tried this based on the code that Jim provided, but it just printed
> > the whole date. I think I just need to tweak it a little, but haven't
> > been able to figure it out.
>
> ______________________________________________
> R-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



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. Received on Tue 24 May 2011 - 18:33:17 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 24 May 2011 - 18:40:09 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.

list of date sections of archive