[R-pkg-devel] Define S4 method for generic in other package

Thierry Onkelinx thierry.onkelinx at inbo.be
Fri Aug 28 10:23:23 CEST 2015


Dear all,

I'm trying to define a new S4 method for a generics defined in an
other package. Here is my attempt, but that isn't working.

bar <- function(a, b) is defined as generic and S4 method in the package foo

#' @importFrom foo bar
#' @importMethodsFrom foo bar
setMethod(
  f = "bar",
  signature = signature(A = "myClass"),
  definition = function(
    a,
    b
  ){
    bar(
      a = myClass at A,
      b = myClass at B
    )
  }
)

When I build my package I get the error "no existing definition for
function 'bar'".

Any suggestions?

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no
more than asking him to perform a post-mortem examination: he may be
able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does
not ensure that a reasonable answer can be extracted from a given body
of data. ~ John Tukey



More information about the R-package-devel mailing list