Under R 1.3.0 on Solaris and Windows NT there seems to be a bug in == when applied to elements of a list, particularly when one of the elements is of mode integer: > list(1) == list(1) [1] FALSE > 1 == list(1) [1] TRUE > as.integer(1)==list(as.integer(1)) [1] FALSE > as.integer(1)==list(as.double(1)) [1] FALSE > list(as.integer(1))==list(as.integer(1)) [1] FALSE > list(as.integer(1))==as.integer(1) [1] FALSE > list(as.double(1))==list(as.double(1)) [1] FALSE However, these cases work: > as.double(1)==list(as.integer(1)) [1] TRUE > list(as.integer(1))==as.double(1) [1] TRUE Replacing the bare integer/double with a vector constructed with c() doesn't change the results, and comparing between vectors created with c() appears correct. -Greg --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = x86 os = Win32 system = x86, Win32 status = major = 1 minor = 3.0 year = 2001 month = 06 day = 22 language = R Windows NT 4.0 (build 1381) Service Pack 5 Search Path: .GlobalEnv, package:ctest, Autoloads, package:base LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Wierd problem comparing numeric values and list using == (PR#1073)
3 messages · Warnes, Gregory R, Peter Dalgaard, John Chambers
gregory_r_warnes@groton.pfizer.com writes:
Under R 1.3.0 on Solaris and Windows NT there seems to be a bug in == when applied to elements of a list, particularly when one of the elements is of mode integer:
> list(1) == list(1)
[1] FALSE
> 1 == list(1)
[1] TRUE
> as.integer(1)==list(as.integer(1))
[1] FALSE
> as.integer(1)==list(as.double(1))
[1] FALSE
> list(as.integer(1))==list(as.integer(1))
[1] FALSE
> list(as.integer(1))==as.integer(1)
[1] FALSE
> list(as.double(1))==list(as.double(1))
[1] FALSE However, these cases work:
> as.double(1)==list(as.integer(1))
[1] TRUE
> list(as.integer(1))==as.double(1)
[1] TRUE Replacing the bare integer/double with a vector constructed with c() doesn't change the results, and comparing between vectors created with c() appears correct.
It is not entirely clear what we *should* be doing here. S (-PLUS 3.4) is at least consistent:
list(1) == list(1)
Error in list(1) == list(1): == operation on mode "list" undefined Dumped
1 == list(1)
Error in 1 == list(1): == operation on mode "list" undefined Dumped
as.integer(1)==list(as.integer(1))
Error in as.integer(1) == list(as.integer(1)): == operation on mode "list"
undefined
Dumped
...
so one might argue that you shouldn't do that in the first place...
(or that the bug is that we do not expressly forbid doing this.)
-p
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
1 day later
Peter Dalgaard BSA wrote:
gregory_r_warnes@groton.pfizer.com writes:
Under R 1.3.0 on Solaris and Windows NT there seems to be a bug in == when applied to elements of a list, particularly when one of the elements is of mode integer:
> list(1) == list(1)
[1] FALSE
> 1 == list(1)
[1] TRUE
> as.integer(1)==list(as.integer(1))
[1] FALSE
> as.integer(1)==list(as.double(1))
[1] FALSE
> list(as.integer(1))==list(as.integer(1))
[1] FALSE
> list(as.integer(1))==as.integer(1)
[1] FALSE
> list(as.double(1))==list(as.double(1))
[1] FALSE However, these cases work:
> as.double(1)==list(as.integer(1))
[1] TRUE
> list(as.integer(1))==as.double(1)
[1] TRUE Replacing the bare integer/double with a vector constructed with c() doesn't change the results, and comparing between vectors created with c() appears correct.
It is not entirely clear what we *should* be doing here. S (-PLUS 3.4) is at least consistent:
list(1) == list(1)
Error in list(1) == list(1): == operation on mode "list" undefined Dumped
1 == list(1)
Error in 1 == list(1): == operation on mode "list" undefined Dumped
as.integer(1)==list(as.integer(1))
Error in as.integer(1) == list(as.integer(1)): == operation on mode "list"
undefined
Dumped
...
so one might argue that you shouldn't do that in the first place...
(or that the bug is that we do not expressly forbid doing this.)
-p
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
As of 1.4, we will have the `identical' function, which is the right way to do such comparisons in any case. So I'd vote for making a use of the comparison operators an error unless the type is correct (or there is a method defined). There is even code in relop.c (commented out) that looks like the right test. Any objections? John
John M. Chambers jmc@bell-labs.com Bell Labs, Lucent Technologies office: (908)582-2681 700 Mountain Avenue, Room 2C-282 fax: (908)582-3340 Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._