调用getGenerics()
给了我一个通用函数及其相应包的列表:
> getGenerics()
An object of class "ObjectsWithPackage":
Object: "-" "!=" "$" "$<-" "%%" "%/%" "&" "*" "/" "[" "[[<-" "[<-" "^" "|" "+"
Package: "base" "base" "base" "base" "base" "base" "base" "base" "base" "base" "base" "base" "base" "base" "base"
Object: "<" "<=" "==" ">" ">=" "abs" "acos" "acosh" "addNextMethod" "Arith" "asin" "asinh" "atan"
Package: "base" "base" "base" "base" "base" "base" "base" "base" "methods" "base" "base" "base" "base"
Object: "atanh" "body<-" "cbind2" "ceiling" "coerce" "coerce<-" "Compare" "Complex" "cos" "cosh" "cospi"
Package: "base" "base" "methods" "base" "methods" "methods" "methods" "base" "base" "base" "base"
Object: "cummax" "cummin" "cumprod" "cumsum" "digamma" "exp" "expm1" "floor" "gamma" "initialize" "kronecker"
Package: "base" "base" "base" "base" "base" "base" "base" "base" "base" "methods" "base"
Object: "lgamma" "loadMethod" "log" "log10" "log1p" "log2" "Logic" "Math" "Math2" "Ops" "rbind2" "round"
Package: "base" "methods" "base" "base" "base" "base" "base" "base" "methods" "base" "methods" "base"
Object: "show" "sign" "signif" "sin" "sinh" "sinpi" "slotsFromS3" "sqrt" "Summary" "tan" "tanh" "tanpi"
Package: "methods" "base" "base" "base" "base" "base" "methods" "base" "base" "base" "base" "base"
Object: "trigamma" "trunc"
Package: "base" "base"
但是如果指定了包getGenerics('package:base')
,则返回null。为什么?如何纠正这个?
> getGenerics('package:base')
An object of class "ObjectsWithPackage":
Object:
Package:
答案 0 :(得分:0)
我们可以使用@
提取所需的那些,因为它是一个S4类
getGenerics()[getGenerics()@package =="base"]