[R] puzzling Date math result
R. Michael Weylandt
michael.weylandt at gmail.com
Tue Apr 17 18:53:41 CEST 2012
A slightly quieter response:
Please use dput() to create a reproducible example -- for this case,
if x and y aren't too long, it seems that dput(x) and dput(y) would
comprise one. str() helps (and thank you for that -- it gave me a
place to start), but it doesn't provide quite enough to reproduce
here.
My guess is that R FAQ 7.31 is in play here... note that
storage.mode(as.Date(Sys.Date())) is double not integer, so you need
to keep an eye on the floating point gremlins.
Michael
On Tue, Apr 17, 2012 at 12:25 PM, Calum Polwart
<yahoo at wittongilbert.free-online.co.uk> wrote:
>
>
> On Tue, 17 Apr 2012 10:44:40 -0400, Denis Chabot wrote:
>
>> Hi,
>>
>
>> I cannot make a reproducible example easily for my problem, so I'll
>>
> describe it as best as I can.
>
> YOU KIND OF NEED ONE...
>
>>>
> a=test1$période[21]
>>
>>> b=test2$date[22]
>> a f
>> argin-left:5px;
> width:100%">b
>>
>> [1] "2011-04-06"
>>
>>>
>
> THIS IS WHY YOU NEED TO
> GIVE US A REPRODUCABLE MEANS BECAUSE IF I SIMPLY DO A="2011-04-06" AND
> B="2011-04-06" I'M GOING TO GET A==B TRUE
>
> WHERE IS THE DATA IN THE DF'S
> BEING SOURCED FROM? IS IT A DATABASE? COULD THERE BE DIFFERENT DATA
> DEFINITIONS? IS ITS A CSV FILE ETC?
>
> and then thi> ft:#1010ff 2px
> solid; margin-left:5px; width:100%">as.integer(a)
>>
>> [1] 15070
>>
>>>
> as.integer(b)
>>
>> [1] 15070
>>
>> SUGGESTION THAT MIGHT POINT YOU IN A
> DIRECTION...
>>
>> as.integer (15070)
> pre>
>
> as.integer (15070.1)
>
> [1]
> 15070
>
> as.integer (15070)==as.integer(15070.1)
>
> [1]
> TRUE
>
> 15070==15070.1
>
> [1] FALSE
>
> SECOND SUGGESTION WOULD BE TO DROP THE
> É NO IDEA WHY THAT WOULD CAUSE A PROBLEM (OR WHERE), BUT ANYTHING THATS
> NOT A-Z OR A-Z ONLY INTRODUCES A POTENTIAL EXTRA HEADACHE...
>
>
> as.integer(a)==as.integer(b)
>
>>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list