[R] Some help with dates.
jim holtman
jholtman at gmail.com
Fri Jun 20 11:35:22 CEST 2008
Check out 'POSIXlt'. This should provide a hint as to how you can do it:
> ?as.POSIXlt
> x <- as.POSIXlt('2008-03-04 11:00')
> x
[1] "2008-03-04 11:00:00 GMT"
> unlist(x)
sec min hour mday mon year wday yday isdst
0 0 11 4 2 108 2 63 0
> ?POSIXlt
> myDate <- paste(x$wday, x$hour)
> myDate
[1] "2 11"
>
On Fri, Jun 20, 2008 at 4:35 AM, Paul Fisch <fischp at gmail.com> wrote:
> Hey,
>
> I'm new to R but familiar with other programming languages.
>
> Basically, I want to store an array of dates. For each of these dates I
> want to store only the day of the week and the hour. So for example:
> "Monday 12" would be Monday at 12 o'clock and "Tuesday 20" would be Tuesday
> at 8 p.m.
>
> Alternatively it could be stored as 0-6 for Sunday to Saturday. So Tuesday
> at 11 a.m. would be something like "2 11".
>
> These dates don't need to be stored exactly like I have written. I just
> would like to know how R would store a day of the week combined with an hour
> in a variable.
>
>
> Thanks,
> Paul
>
> [[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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list