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

Thierry Onkelinx thierry.onkelinx at inbo.be
Tue Sep 1 10:53:09 CEST 2015


Dear Hadley,

I've put a reproducible example at https://github.com/ThierryO/testS4

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


2015-09-01 0:32 GMT+02:00 Hadley Wickham <h.wickham at gmail.com>:
> I'd recommend creating a minimal package that illustrates the problem
> using an existing S4 generic in a base package (e.g. stats4::AIC).
> That makes it easier to figure out what's gone wrong.
>
> It's unlikely to be a roxygen2 problem since the translation from
> @importFrom foo bar (etc) to importFrom(foo, bar) is quite
> straightforward.
>
> Hadley
>
> On Fri, Aug 28, 2015 at 3:23 AM, Thierry Onkelinx
> <thierry.onkelinx at inbo.be> wrote:
>> 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
>>
>> ______________________________________________
>> R-package-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>
>
> --
> http://had.co.nz/



More information about the R-package-devel mailing list