how to extend a reference class defined in an R package?

限于喜欢 提交于 2019-12-12 17:30:08

问题


I want to allow users to extend a reference class I define in my package. Here is a toy example:

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

After loading this package, I get a warning when I try to extend it:

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’

How do I get rid of this warning?


回答1:


Remember to export the class definition from your package, in the my_package/NAMESPACE file add

exportClasses("Main")


来源:https://stackoverflow.com/questions/17452112/how-to-extend-a-reference-class-defined-in-an-r-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!