[R] generating a sequence of seconds

William Dunlap wdunlap at tibco.com
Tue Aug 12 21:14:25 CEST 2014


> What if I just want the seconds vector without the date, please?  Is there
> a convenient way to create such a vector, please?

Why do you want such a thing?  E.g., do you want it to print the time
of day without the date?  Or are you trying to avoid numeric problems
when you do regressions with the seconds-since-1970 numbers around
1414918800?  Or is there another problem you want solved?

Note that the number of seconds in a day depends on the day and the
time zone.  In US/Pacific time I get:

  > length(seq(from=as.POSIXct("2014-08-12
00:00:00"),to=as.POSIXct("2014-08-12 23:59:59"), by="secs"))
  [1] 86400
  > length(seq(from=as.POSIXct("2014-03-09
00:00:00"),to=as.POSIXct("2014-03-09 23:59:59"), by="secs"))
  [1] 82800
  > length(seq(from=as.POSIXct("2014-11-02
00:00:00"),to=as.POSIXct("2014-11-02 23:59:59"), by="secs"))
  [1] 90000

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Tue, Aug 12, 2014 at 11:51 AM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
> Hello!
>
> If I would like to generate a sequence of seconds for a date, I would do
> the following:
>
> x <- seq(from=as.POSIXct(2014-08-12 00:00:00),to=as.POSIXct(2014-08-12
> 23:59:59),by="secs")
>
> What if I just want the seconds vector without the date, please?  Is there
> a convenient way to create such a vector, please?
>
> thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>
>         [[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.



More information about the R-help mailing list