Re: [R] Handling Time in R

2011-10-10 Thread Alaios
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.399 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
 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.


Re: [R] Handling Time in R

2011-10-10 Thread Jim Holtman
check the help page; there is a parameter ('units' I thnk) that will let you 
specify that.

Sent from my iPad

On Oct 10, 2011, at 2:57, 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
 To: Alaios ala...@yahoo.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.399 secs
 
 
 
 On Fri, Oct 7, 2011 at 11:04 AM, Alaios ala...@yahoo.com wrote:
  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.0006.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
  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.


Re: [R] Handling Time in R

2011-10-10 Thread Alaios
This did the trick

as.numeric(diff(c(ISOdatetime(2011,6,1,11,59,1.09),ISOdatetime(2011,6,5,11,59,1.09
[1] 345600





From: Jim Holtman jholt...@gmail.com

Cc: R-help@r-project.org R-help@r-project.org
Sent: Monday, October 10, 2011 9:26 AM
Subject: Re: [R] Handling Time in R


check the help page; there is a parameter ('units' I thnk) that will let you 
specify that.

Sent from my iPad




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.399 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
 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.


Re: [R] Handling Time in R

2011-10-10 Thread Jeff Newmiller
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.399 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
 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.


Re: [R] Handling Time in R

2011-10-10 Thread Alaios
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

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 NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.



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.399 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.


Re: [R] Handling Time in R

2011-10-10 Thread Jeff Newmiller
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.399 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.


Re: [R] Handling Time in R

2011-10-10 Thread Alaios
Thanks a lot for your answer.
It is something that I do not understand with R how the wrapper functions work 
really.
As an example, check the code below   
TimeDiffInSeconds-diff((ISOdate(timeMatrix[,1],timeMatrix[,2],timeMatrix[,3],timeMatrix[,4],timeMatrix[,5],timeMatrix[,6])),units=secs);       
 
returns an error

even though I make it

   
TimeDiffInSeconds-difftime((ISOdate(timeMatrix[,1],timeMatrix[,2],timeMatrix[,3],timeMatrix[,4],timeMatrix[,5],timeMatrix[,6])),units=secs);       
 

I would like to thank you in advance for your help

B.R
Alex




From: Jeff Newmiller jdnew...@dcn.davis.ca.us

Cc: R-help@r-project.org R-help@r-project.org
Sent: Monday, October 10, 2011 12:23 PM
Subject: Re: [R] Handling Time in R


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



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

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 NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.



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.399 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

Re: [R] Handling Time in R

2011-10-07 Thread jim holtman
?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.399 secs



On Fri, Oct 7, 2011 at 11:04 AM, Alaios ala...@yahoo.com wrote:
 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
 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?

__
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.