Dear all, I am trying to define "+" method for my newly defined s4 class
which is as follows:

 

setClass("Me", sealed=F,representation(x1 = "numeric", x2 = "character"))

new1 <- new("Me", x1=2, x2="comment1")

new2 <- new("Me", x1=3, x2="comment1")

 

setMethod("+", "Me", definition=function(x,y) cat(x@x1 + y@x1, "\n"))

 

However while am trying to set method, it fails:

Error in conformMethod(signature, mnames, fnames, f, fdef, definition) : 

  in method for '+' with signature 'e1="Me"': formal arguments (e1 = "Me",
e2 = "Me") omitted in the method definition cannot be in the signature

 

I am just started learning s4 class system therefore please forgive me if I
have some any bad mistakes. Anyway I would really appreciate if someone
point me how should I proceed.

 

Thanks and reagrds,


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to