If you add @export A
then the generator function A
will be exported, too, e.g.
#' A class description
#'
#' @import methods
#' @export A
#' @exportClass A
A = setRefClass('A',
fields=list(name='character', n='numeric'),
methods=list(
hello=function() {
"A greeting"
return(paste0('Hello, ', name))
}
)
)
Important: Don't forget to explicitly mention A
in the export directive or it doesn't appear to work, unlike for functions.
Alternatively, as the class is being exported, you can still use the class via new()
, e.g.
> a = new('A', name='Josh', n=12345)
> a$hello()
[1] "Hello, Josh"
but it's easy to just add the export.