Skip to content
Prev 369706 / 398503 Next

Math ops behaviour with multiple classes

I think you may be confusing (S3) class and ?mode.
[1] "integer"
[1] "numeric"
[1] "numeric"
[1] "numeric"

But note:
[1] "integer"
[1] "numeric"
[1] "foo"
[1] "numeric"

And further:
[1] "foo"     "integer"

So basically, the behavior seems to be: when the class attribute can
be coerced to "numeric" by as.numeric(), it is. Otherwise it is left
as is.

Note that log is a primitive function not in the Ops groups, but has
similar behavior.

I would guess (corroboration or correction by more knowledgeable folks
appreciated!) that this sort of semi-confusion with S3 classes was one
of the motivators for adding the more rigorous S4 system.

HTH

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Jun 8, 2017 at 9:40 AM, Cole Beck <cole.beck at vanderbilt.edu> wrote: