No, read ?difftime and look at as.double. There is a units parameter that you 
must set if you want predictable results.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Alaios <ala...@yahoo.com> wrote:

Do you mean something like that?


as.double(diff(c(ISOdatetime(2011,6,1,11,59,1.09),ISOdatetime(2011,6,5,11,59,1.09))),length=20)
[1] 345600


_____________________________________________
From: Jeff Newmiller <jdnew...@dcn.davis.ca.us>
To: Alaios <ala...@yahoo.com>; jim holtman <jholt...@gmail.com>
Cc: "R-help@r-project.org" <R-help@r-project.org>
Sent: Monday, October 10, 2011 10:42 AM
Subject: Re: [R] Handling Time in R

Difftime doesn't "report" things. When you print it, it automatically selects 
an appropriate human-readable unit to display in, but that does not change its 
internal representation. If you must convert to seconds, you can do so using 
the as.double generic (as.double.difftime) with a units parameter.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Alaios <ala...@yahoo.com> wrote:

Thanks a lot. 

That helped.
One thing now is to have the difftime(y,x) to always report seconds. There are 
times that there is a change in the day and thus the diff will report few days 
difference. How can it always report only seconds?

I would like to thank you in advance for your help

B.R
Alex



_____________________________________________

From: jim holtman <jholt...@gmail.com>

Cc: "R-help@r-project.org" <R-help@r-project.org>
Sent: Friday, October 7, 2011 5:34 PM
Subject: Re: [R] Handling Time in R

?ISOdatetime


> x <- ISOdatetime(2011,10,6,16,23,30.539)
> str(x)
POSIXct[1:1], format: "2011-10-06 16:23:30"
> y <- ISOdatetime(2011,10,6,16,23,30.939)
> difftime(y,x)
Time difference of 0.3999999 secs
>



> Dear all,
> I would like to ask your help regarding handling time stamps in R. I think 
> first I need a reference to read about their logic and how I should handle 
> them.
>
> For example, this is a struct I have
>
>
> str(MyStruct$TimeStamps)
> �num [1:100, 1:6] 2011 2011 2011 2011 2011 ...
>
> MyStruct$TimeStamps[1,]
> [1] 2011.000�� 10.000��� 6.000�� 16.000�� 23.000�� 
> 30.539
>
> the last field contains seconds.milliseconds.
>
> How I can for example make calculations with time stamps like see if the
> MyStruct$TimeStamps[1,]-MyStruct$TimeStamps[2,] differ more than 
> 300millisecond, or 3 days have passed?
>
> I would like to thank you in advance for your suggestions
>
> B.R
> Alex
>
> � � � �[[alternative HTML version deleted]]
>
>
>_____________________________________________

> R-help@r-project.org mailing list< br />> 
> 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
Data Munger Guru

What is the problem that you are trying to solve?
        [[alternative HTML version deleted]]

_____________________________________________

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.




        [[alternative HTML version deleted]]

______________________________________________
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