问题
I want to export an S3method named [.myclass using roxygen2 and I can't see a clean way to do this.
I need NAMESPACE to have
S3method("[",myclass)
in it or the method can't be used after I require the package, but roxygen2 doesn't appear to want to help me with this.
I can force it to with
#' @S3method [ myclass
setMethodS3("[",
c(x="myclass"),
function(x,i) {
blah blah balh
})
but roxygen then says that s3method is deprecated and that I should use @export instead, but
#' @export
setMethodS3("[",
c(x="myclass"),
function(x,i) {
blah blah balh
})
just doesn't do it. (puts an empty export in the NAMESPACE).
I asked the author of the package and he suggested i use @method and @export, but this also doesn't work
#' @method [ myclass
#' @export
setMethodS3("[",
c(x="myclass"),
function(x,i) {
blah blah balh
})
also ends up with "export()" in the NAMESPACE
What am I missing?
回答1:
Answer:
Hadley was incredibly helpful and now I realize that I shouldn't be using setMethodS3 but instead just
#' @method [ myclass
#' @export
"[.myclass" <- function(x,i) { blah blah blah }
and then everything works great.
来源:https://stackoverflow.com/questions/29360132/use-roxygen-to-make-s3method-in-namespace