Shahab Einabadi
Shahab Einabadi

Reputation: 332

what is the object type of mean in R?

I am looking for the real object type of some functions in R, for example, I can not find out the object type of mean function.

> library(pryr)
> otype(mean)
[1] "base"
> ftype(mean)
[1] "s3"      "generic"

Sometimes the mean function is S3 and sometimes it is base!

Upvotes: 1

Views: 216

Answers (1)

M--
M--

Reputation: 28825

What does ftype tell us?

This function figures out whether the input function is a regular/primitive/internal function, a internal/S3/S4 generic, or a S3/S4/RC method. This is function is slightly simplified as it’s possible for a method from one class to be a generic for another class, but that seems like such a bad idea that hopefully no one has done it.

What does otype give us?

Figure out which object system an object belongs to:

• base: no class attribute

• S3: class attribute, but not S4

• S4: isS4, but not RC

• RC: inherits from "refClass"

For reference:

  1. pryr package documentation

  2. R language objects

Upvotes: 2

Related Questions