My problem is essentially the same as outlined in this unanswered question that resulted in a filed, and successfully closed bug report.
Given an existing S4 generic
, in my case diag
and diag<-
, I wish to export an implementation for an S4 class
from another package.
Reading through another thread I have discovered that i can successfully export these functions if I use the tags @exportMethod diag<-
and @exportMethod diag
respectively, but I can't get the documentation to work.
The first thread and subsequent closed bug report, suggests that the following should work (in this case for the method show
):
#' @export
#' @aliases show,myPkgSpClass-method
#' @rdname myPkgSpClass-class
setMethod("show", "myPkgSpClass", function(object){ show(NA) })
However when I try to do the following for diag
, I get an error when i try to build:
#' @export
#' @aliases diag<-,big.matrix-method
#' @rdname bigmatrix-diag
setMethod("diag<-", signature("big.matrix"), function(x, value) {
SetDiag(x@address, value) # C++ implementation
x
})
#' @export
#' @aliases diag,big.matrix-method
#' @rdname bigmatrix-diag
setMethod("diag", signature("big.matrix"), function(x) {
GetDiag(x@address) # C++ implementation
})
The error: Error : Sections \title, and \name must exist and be unique in Rd files
.
Clarification: Currently no implementation of diag
is available for this class.
EDIT: Resolving the error:
I can resolve this error, but not without clobbering the existing documentation for diag
.
If I add a unique name and title as follows it will successfully builds:
#' @name diag
#' @title Extract and Replace the diagonal from a big.matrix
#' @aliases diag<-,big.matrix-method
#' @docType methods
#' @exportMethod diag<-
#' @rdname bigmatrix-diag
setMethod("diag<-", signature("big.matrix"), function(x, value) {
SetDiag(x@address, value)
x
})
#' @name diag
#' @title Extract and Replace the diagonal from a big.matrix.
#' @aliases diag,big.matrix-method
#' @docType methods
#' @exportMethod diag
#' @rdname bigmatrix-diag
setMethod("diag", signature("big.matrix"), function(x) {
GetDiag(x@address)
})
But when i type ?diag
in an R session I get the error:
Error in (function (path, query, ...) : replacement has length zero
Which i think means its finding two helpfiles for
diag`.
Could you try this ?