I think this demonstrate on of the differences between Class 'Date' and
'POSIXlt'. Thanks, Marc!
...Tao
From: Marc Schwartz
To: Ben Bolker
Cc: "Shi, Tao" ; "r-h...@stat.math.ethz.ch"
Sent: Saturday, October 30, 2010 7:48:05 AM
Subject: Re: [R] dat
From: Ben Bolker
To: "Shi, Tao"
Cc: "r-h...@stat.math.ethz.ch"
Sent: Saturday, October 30, 2010 7:22:04 AM
Subject: Re: [R] date calculation
On 10-10-30 02:02 AM, Shi, Tao wrote:
> Hi Ben,
>
> That must be the case! In fact if I do:
>
>> difftime(strp
t = "%d/%m/%Y")
Date1 <- as.Date("13/05/2004", format = "%d/%m/%Y")
> Date2 - Date1
Time difference of 195 days
R has built in arithmetic operations for such dates, without the need to use
another package, since they are effectively numerics with a Date clas
uggest the chron package:
library(chron)
diff(chron(dates.=c("24/11/2004","13/05/2004"),format="d/m/y"))
>
>
>
> - Original Message -
>> From:Ben Bolker
>> To:r-h...@stat.math.ethz.ch
>> Cc:
>> Sent:Friday, Octo
t;), units="hours")
Time difference of 4681 hours
> 195 * 24 + 1
[1] 4681
In short, difftime() is performing as stated and documented (if
slightly unexpected at first glance).
Cheers,
Josh
>
> Thanks!
>
> ...Tao
>
>
>
>
>
> - Original Message -
>> F
someone from the R development team confirm this?
Thanks!
...Tao
- Original Message -
> From:Ben Bolker
> To:r-h...@stat.math.ethz.ch
> Cc:
> Sent:Friday, October 29, 2010 7:54:53 PM
> Subject:Re: [R] date calculation
>
>
> Shi, Tao
> href="http://
Hi Phil,
Thanks for the reply, but I don't think you have
explained where the decimal part is coming from
...Tao
- Original Message -
> From:Phil Spector
> To:"Shi, Tao"
> Cc:r-h...@stat.math.ethz.ch
> Sent:Friday, October 29, 2010 5:04:23 PM
> Su
Shi, Tao yahoo.com> writes:
> Could someone explain to me why the following result is not a integer?
>
> > difftime(strptime("24NOV2004", format="%d%b%Y"), strptime("13MAY2004",
> >format="%d%b%Y"), units="days")
> Time difference of 195.0417 days
Presumably because this goes across a daylig
Tao -
The documentation for the difftime function says:
Function ‘difftime’ calculates a difference of two date/time
objects and returns an object of class ‘"difftime"’ with an
attribute indicating the units.
So that answers your question.
If you want it to be an integer, you're ce
Hi list,
Could someone explain to me why the following result is not a integer?
> difftime(strptime("24NOV2004", format="%d%b%Y"), strptime("13MAY2004",
>format="%d%b%Y"), units="days")
Time difference of 195.0417 days
I'm using R2.12.0 on WinXP.
Thanks!
...Tao
_
10 matches
Mail list logo