I want to write a package using S4 objects and need to register new generic functions. I want to split my code into several files - each class gets its own .R file. However their methods share of course common generic functions. Where do I need to call setGeneric()
such that I can use setMethod()
in any .R file of the package? Currently I get an error of the type
Error in setMethod("XXX", signature(yyy = "YYY"), definition = function(yyy, :
no existing definition for function 'XXX'
Organize your code however you see fit (e.g., an AllGenerics.R file, or a XXX-methods.R file that starts with the generic). Use the 'Collate:' field in the DESCRIPTION file to ensure that the generics are available before methods defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With