[Rd] bug or feature? (PR#4150)

John Fox jfox at mcmaster.ca
Sat Sep 13 10:01:59 MEST 2003


Dear Axel,

At 01:37 PM 9/13/2003 +0200, axel.benz at iao.fhg.de wrote:
>Full_Name: Axel Benz
>Version: 1.7.1
>OS: Windows
>Submission from: (NULL) (137.251.33.43)
>
>
>This feature seems to be a basic bug:
>
> > 1=="1"
>[1] TRUE
> > as.numeric(1)=="1"
>[1] TRUE
> > as.numeric(1)==as.character("1")
>[1] TRUE
>
>isn't it necessary to distinguish beteen numbers and characters??

Coercion to a common mode takes place in many contexts; for example:

         > 1 & TRUE
         [1] TRUE

To distinguish between numbers and characters you can, of course, use the 
predicates is.numeric() and is.character(), or test that the mode() of the 
arguments is the same.

John
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox



More information about the R-devel mailing list