[R] generating a sequence of seconds

Marc Schwartz marc_schwartz at me.com
Tue Aug 12 22:10:56 CEST 2014


On Aug 12, 2014, at 2:49 PM, John McKown <john.archie.mckown at gmail.com> wrote:

> And some people wonder why I absolutely abhor daylight saving time.
> I'm not really fond of leap years and leap seconds either. Somebody
> needs to fix the Earth's rotation and orbit!


I have been a longtime proponent of slowing the rotation of the Earth on its axis, so that we could have longer days to be more productive.

Unfortunately, so far, my wish has gone unfulfilled...at least as it is relevant within human lifetimes.

;-)

Regards,

Marc


> 
> On Tue, Aug 12, 2014 at 2:14 PM, William Dunlap <wdunlap at tibco.com> wrote:
>>> 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



More information about the R-help mailing list