[R] problems with setClass or/and setMethod
David Winsemius
dwinsemius at comcast.net
Mon Jun 10 09:56:30 CEST 2013
On Jun 9, 2013, at 11:37 PM, andreas betz wrote:
> Hello,
>
> I am working my way through "A (not so) Short introduction to S4"
>
> I created a class
>
> setClass(Class = "Trajectories",
> representation = representation(times = "numeric",traj = "matrix"))
>
> and tried to build a method using
>
> setMethod(
> f = "plot",
> signature = "Trajectories",
> definition = function(X, y, ...){
> matplot(x at times, t(x at traj), xaxt = "n", type = "l", ylab = "",
> xlab = "", pch = 1)
> axis(1, at = x at times)
> }
> )
>
> R responds with an error message:
>
> Creating a generic function for Œplot‚ from package Œgraphics‚ in the
> global environment
> Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
> in method for Œplot‚ with signature Œx="Trajectories"‚: formal arguments
> (x = "Trajectories", y = "Trajectories", ... = "Trajectories") omitted in
> the method definition cannot be in the signature
>
> Did anything change in the transition to R-3.0?
I doubt it worked in earlier versions. There is a misprint of "X" where there should be an "x". I'm unable to explain why the "y" is along side the "x" in the argument list since the 'definition' function does nothing with it.
>
> is there any other, more recent introduction to S4 classes recommended?
>
> Thank you
>
> for your help.
>
> Andreas
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list