Erin,

Is a sequential resolution of seconds required, as per your original post?

If so, then using my approach and specifying the start and end dates and times 
will work, with the coercion of the resultant vector to numeric as I included. 
The method I used (subtracting the first value) will also give you the starting 
second as 0, or you can alter the math to adjust the origin of the vector as 
you desire.

As Bill notes, there will be some days where the number of seconds in the day 
will be something other than 86,400. In Bill's example, it is due to his 
choosing the start and end dates of daylight savings time in a relevant time 
zone. Thus, his second date is short an hour, while the third has an extra hour.

Regards,

Marc


On Aug 12, 2014, at 2:26 PM, Erin Hodgess <erinm.hodg...@gmail.com> wrote:

> What I would like to do is to look at several days and determine activities
> that happened at times on those days.  I don't really care which days, I
> just care about what time.
> 
> Thank you!
> 
> 
> 
> 
> On Tue, Aug 12, 2014 at 3:14 PM, William Dunlap <wdun...@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.hodg...@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

______________________________________________
R-help@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.

Reply via email to