2

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

# 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’

我如何摆脱这个警告?

4

1 回答 1

1

记得从你的包中导出类定义,在 my_package/NAMESPACE 文件中添加

exportClasses("Main")
于 2013-07-03T15:47:20.243 回答