如何扩展R包中定义的引用类?

时间:2013-07-03 15:30:12

标签: r reference-class

我想允许用户扩展我在包中定义的引用类。这是一个玩具示例:

# my_package/R/Main.R
#' My Main class
#' @export
Main <- setRefClass("Main")

加载此软件包后,当我尝试扩展它时会收到警告:

library(my_package)
Child <- setRefClass("Child", contains = "Main")
# Warning message:
# Class "Main" is defined (with package slot ‘my_package’) but no metadata object found to revise subclass information---not exported?  Making a copy in package ‘.GlobalEnv’

如何摆脱此警告?

1 个答案:

答案 0 :(得分:1)

请记住从包中导出类定义,在my_package / NAMESPACE文件中添加

exportClasses("Main")