[R] R difftime function: How can we fix the difftime unit?

2007-03-21 Thread d. sarthi maheshwari
Hi,

I am trying to take difference of two time objects. I want to fix the
result's unit to minutes. How can I do that?

Here is an example:

 difftime(x, y)
Time difference of 2.030720 hours
 difftime(x, z)
Time difference of 30.34672 mins

where x = '2007-03-05 08:32:58'
  y = '2007-03-05 06:31:07'
andz = '2007-03-05 08:02:37'

How can I get answer something like

for (x-y)
Time difference of 121.8432 mins

and for (x-z)
Time difference of 30.34672 mins

Kindly help.

-- 
Thanks  Regards
Sarthi M.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] R difftime function: How can we fix the difftime unit?

2007-03-21 Thread Frede Aakmann Tøgersen
That's easy:
 
difftime(x, y, units = min)
 
Best regards
 
Frede



Fra: [EMAIL PROTECTED] på vegne af d. sarthi maheshwari
Sendt: to 22-03-2007 07:03
Til: r-help@stat.math.ethz.ch
Emne: [R] R difftime function: How can we fix the difftime unit?



Hi,

I am trying to take difference of two time objects. I want to fix the
result's unit to minutes. How can I do that?

Here is an example:

 difftime(x, y)
Time difference of 2.030720 hours
 difftime(x, z)
Time difference of 30.34672 mins

where x = '2007-03-05 08:32:58'
  y = '2007-03-05 06:31:07'
andz = '2007-03-05 08:02:37'

How can I get answer something like

for (x-y)
Time difference of 121.8432 mins

and for (x-z)
Time difference of 30.34672 mins

Kindly help.

--
Thanks  Regards
Sarthi M.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.

__
R-help@stat.math.ethz.ch 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] R difftime function: How can we fix the difftime unit?

2007-03-21 Thread Marc Schwartz
On Thu, 2007-03-22 at 11:33 +0530, d. sarthi maheshwari wrote:
 Hi,
 
 I am trying to take difference of two time objects. I want to fix the
 result's unit to minutes. How can I do that?
 
 Here is an example:
 
  difftime(x, y)
 Time difference of 2.030720 hours
  difftime(x, z)
 Time difference of 30.34672 mins
 
 where x = '2007-03-05 08:32:58'
   y = '2007-03-05 06:31:07'
 andz = '2007-03-05 08:02:37'
 
 How can I get answer something like
 
 for (x-y)
 Time difference of 121.8432 mins
 
 and for (x-z)
 Time difference of 30.34672 mins
 
 Kindly help.


See ?difftime and take note of the 'units' argument:

 difftime(x, y, units = mins)
Time difference of 121.85 mins

 difftime(x, z, units = mins)
Time difference of 30.35 mins

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch 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.