Reputation: 2065
I was typing some code in R and noticed that
> any(range(2.0,3.0))
gave me the following:
Warning message:
In any(range(2, 3)) : coercing argument of type 'double' to logical
I looked up the help function by typing ? any
and got the following:
Coercion of types other than integer (raw, double, complex, character, list) gives a warning as this is often unintentional.
So I typed any(range(2,3))
and still got the same warning. Am I doing something wrong?
Upvotes: 0
Views: 3485
Reputation: 545995
Why are you using the function like that? As the documentation says, a coercion happens because any
is called on logical values (TRUE
, FALSE
). It makes little sense on other values.
As for why you’re still getting the error: in R, 2
and 3
are numerics, not integers. You could use any(range(2L, 3L))
but this isn’t really any more meaningful. In fact, R should warn here as well.
Upvotes: 1