R 中 mean 的对象类型是什么?
what is the object type of mean in R?
我正在寻找R中某些函数的真实对象类型,例如,我找不到mean函数的对象类型。
> library(pryr)
> otype(mean)
[1] "base"
> ftype(mean)
[1] "s3" "generic"
有时候均值函数是S3,有时候是base!
ftype
告诉我们什么?
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.
otype
给了我们什么?
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"
供参考:
我正在寻找R中某些函数的真实对象类型,例如,我找不到mean函数的对象类型。
> library(pryr)
> otype(mean)
[1] "base"
> ftype(mean)
[1] "s3" "generic"
有时候均值函数是S3,有时候是base!
ftype
告诉我们什么?
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.
otype
给了我们什么?
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"
供参考: