我正在尝试使用length()
类上的函数item
来显示向量options
的长度。
setClass(Class = "item",
representation = representation(
options = "character"
),
prototype = prototype(
options = character()
)
)
setGeneric("length")
setMethod("length", signature(x = "item"), definition = function(x) length(x@options))
但是,我总是收到以下错误:
Error: could not find function "getGeneric"
Warning:
In .rk.get.structure.global(".__C__item") :
failure to get object .__C__item
我正在使用R version 2.13.2 (2011-09-30)
和RKWard版本0.5.7z + 0.5.8 + devel1。
答案 0 :(得分:1)
默认情况下,methods
包在启动时不会加载。呼叫
library(methods)