[R] odd behaviour of identical

Patrick Burns pburns at pburns.seanet.com
Mon Oct 27 09:56:27 CET 2008


Wacek Kusnierczyk wrote:
> smells bad design.
>   

Nonsense. 

One of the key design features of R is that it
hides implementation details from users.  They
are free to think about the substantive issues with
their data rather than worrying about computational
trivia.

There may have been some, but I don't recall a
time when I've ever needed to know if a vector in R
was integer or double.


Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
> jim holtman wrote:
>   
>> If you want them to be identical, then you have to explicitly assign
>> an integer to the vector so that conversion is not done:
>>
>>   
>>     
>>> x = 1:10
>>> y = 1:10
>>>
>>> all.equal(x,y)
>>>     
>>>       
>> [1] TRUE
>>   
>>     
>>> identical(x,y)
>>>     
>>>       
>> [1] TRUE
>>   
>>     
>>> y[11] = 11L
>>> y = y[1:10]
>>>
>>> all.equal(x,y)
>>>     
>>>       
>> [1] TRUE
>>   
>>     
>>> identical(x,y)
>>>     
>>>       
>> [1] TRUE
>>   
>>
>>
>> On Sun, Oct 26, 2008 at 6:39 PM, Wacek Kusnierczyk
>> <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
>>   
>>     
>>> given what ?identical says, i find the following odd:
>>>
>>> x = 1:10
>>> y = 1:10
>>>
>>> all.equal(x,y)
>>> [1] TRUE
>>> identical(x,y)
>>> [1] TRUE
>>>
>>> y[11] = 11
>>> y = y[1:10]
>>>
>>> all.equal(x,y)
>>> [1] TRUE
>>> identical(x,y)
>>> [1] FALSE
>>>
>>> y
>>> [1] 1 2 3 4 5 6 7 8 9 10
>>> length(y)
>>> [1] 10
>>>
>>>
>>> looks like a bug.
>>>
>>> platform       i686-pc-linux-gnu
>>> arch           i686
>>> os             linux-gnu
>>> system         i686, linux-gnu
>>> status
>>> major          2
>>> minor          7.0
>>> year           2008
>>> month          04
>>> day            22
>>> svn rev        45424
>>> language       R
>>> version.string R version 2.7.0 (2008-04-22)
>>>
>>>
>>> vQ
>>>
>>> --
>>> -------------------------------------------------------------------------------
>>> Wacek Kusnierczyk, MD PhD
>>>
>>> Email: waku at idi.ntnu.no
>>> Phone: +47 73591875, +47 72574609
>>>
>>> Department of Computer and Information Science (IDI)
>>> Faculty of Information Technology, Mathematics and Electrical Engineering (IME)
>>> Norwegian University of Science and Technology (NTNU)
>>> Sem Saelands vei 7, 7491 Trondheim, Norway
>>> Room itv303
>>>
>>> Bioinformatics & Gene Regulation Group
>>> Department of Cancer Research and Molecular Medicine (IKM)
>>> Faculty of Medicine (DMF)
>>> Norwegian University of Science and Technology (NTNU)
>>> Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
>>> Room 231.05.060
>>>
>>> ______________________________________________
>>> 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