You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"the recommended approach is to do both: register the S3 method and supply the identical function as the definition of the S4 method. This ensures that the proposed method will be dispatched for any applicable call to the function."
This requires, as per example in ?Methods_for_S3:
S3 method: method.class <- function()
S4 method: setMethod("method", "class", function())
And in the namespace file:
S3 method export: S3method(method, class)
S4 method export: exportMethod(method)
S3 methods, without S4 generic by default
As specifically recommended, these should receive a corresponding S4 method. There would be no need to define the S4 generic method itself (ie setGeneric(summary)) because setting "an S4 method, which will have the side effect of creating an S4 generic version of this function". However, explicit is better than implicit, therefore define S4 generics as well.
This includes:
predict
summary
print
plot
all from stats coef, vcov, nobs, etc
S4 methods, without S3 generic by default
S4 objects use show instead of print. Define the method for print forward from S4 show as implicitly recommended ("supply the identical function as the definition of the S4 method").
Exported CLVTools S4 methods
These should also define and receive corresponding S3 methods and implementations for all clv.data classes and a default with only stop().
As of now, exporting an S3 standard method as S4 generic leads to troubles with roxygen. It can apparently handle a function only as either S3 or S4 and otherwise exports them wrongly as non-generics. Because this feature is not really important, its put on hold.
Are S4 methods needed where only S3 methods exist?
Are S3 methods needed where only S4 methods exist?
Reference: https://stackoverflow.com/questions/32512785/properly-specify-s4-generics
The text was updated successfully, but these errors were encountered: