[Rd] bug or feature? (PR#4150)
dmurdoch at pair.com
Sat Sep 13 09:42:13 MEST 2003
On Sat, 13 Sep 2003 13:37:28 +0200 (MET DST), you wrote:
>Full_Name: Axel Benz
>Submission from: (NULL) (18.104.22.168)
>This feature seems to be a basic bug:
>isn't it necessary to distinguish beteen numbers and characters??
No, the general rule in R is that operators try to coerce their
arguments into a suitable type for the operation. In this case,
because one arg is character, the other one is coerced to character
too. It doesn't matter that you forced the type using as.numeric or
as.character; the operator is going to force them both to comparable
> pi == "3.14159265358979"
> pi == 3.14159265358979
In the last case, they were already comparable, so no forcing was
done. Since the internal value of pi actually carries more than 14
decimal places of precision, they don't compare equal as numbers, even
though the do compare equal when converted to character.
If you want to distinguish numbers and characters, use mode(1) ==
More information about the R-devel