问题
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