Message-ID: <4AEE672F.2090507@huesing.name>
Date: 2009-11-02T04:59:27Z
From: Johannes Hüsing
Subject: unusual result with "any"
In-Reply-To: <7acc7a990911012049qc43ce0bsa546ee7e1ea346c7@mail.gmail.com>
Erin Hodgess schrieb:
>
>> xy
>>
> [1] 0.7305081 2.4224211
>
>> str(xy)
>>
> num [1:2] 0.73 2.42
>
>> any(xy) > 1
>>
> [1] FALSE
> Warning message:
> In any(xy) : coercing argument of type 'double' to logical
>
>
> What am I doing wrong please?
>
>
xy > 1 should return TRUE FALSE, and you want to apply any() to that.
Thus: any(xy > 1)
any(xy) returns TRUE, as the nonzero numbers are coerced to TRUE
When TRUE is compared with 1, it is coerced to a number (no warning is
issued here), namely 1.
1 > 1 returns FALSE.