I have written a package using S4 classes and would like to use the functions rbind, cbind with these defined classes.
Since it does not seem to be possible to define rbind
and cbind
directly as S4 methods I defined rbind2
and cbind2
instead:
setMethod("rbind2", signature(x="ClassA", y = "ANY"),
function(x, y) {
# Do stuff ...
})
setMethod("cbind2", signature(x="ClassA", y = "ANY"),
function(x, y) {
# Do stuff ...
})
From ?cbind2
I learned that these functions need to be activated using methods:::bind_activation
to replace rbind and cbind from base.
I included the call in the package file R/zzz.R using the .onLoad
function:
.onLoad <- function(...) {
# Bind activation of cbind(2) and rbind(2) for S4 classes
methods:::bind_activation(TRUE)
}
This works as expected. However, running R CMD check I am now getting the following note since I am using an unexported function in methods:
* checking dependencies in R code ... NOTE
Unexported object imported by a ':::' call: 'methods:::bind_activation'
See the note in ?`:::` about the use of this operator.
How can I get rid of the NOTE and what is the proper way to define the methods cbind and rbind for S4 classes in a package?