Re: [Rd] how to define method for "+" function in a new class

From: <james.foadi_at_diamond.ac.uk>
Date: Wed, 07 Jul 2010 16:16:50 +0100

I don't know why a "3D" appears instead of a "(". Please, interpret a "( whenever you see a "3D".

J

Dr James Foadi PhD
Membrane Protein Laboratory (MPL)
Diamond Light Source Ltd
Diamond House
Harewell Science and Innovation Campus
Chilton, Didcot
Oxfordshire OX11 0DE

Email : james.foadi_at_diamond.ac.uk
Alt Email: j.foadi_at_imperial.ac.uk

-----Original Message-----
From: r-devel-bounces_at_r-project.org on behalf of james.foadi_at_diamond.ac.uk Sent: Wed 07/07/2010 16:09
To: r-devel_at_r-project.org
Subject: [Rd] how to define method for "+" function in a new class  

Dear R developers,
I have a new class, which I called "Molecule", and have tried to define = a "+" operation for 2 objects of this class. This is what I have written so far, although the method is not complete = (I'm trying to look at it at intermediate stages):

setMethod(

          f=3D"+",
          signature(x=3D"Molecule",y=3D"Molecule"),
          definition=3Dfunction(x,y,...)
                     {

# Check both objects are correct
checkMolecule(x) checkMolecule(y)
# Extract chains information
ch1 <- getMoleculeChains(x) ch2 <- getMoleculeChains(y) union_ch <- unique(c(ch1,ch2)) not_used <- .ALPHABET for (i in seq(along =3D union_ch)) { idx <- which(not_used !=3D union_ch[i]) if (length(idx) !=3D 0) not_used <- not_used[idx] } return(not_used) } )

The definition of class Molecule is included earlier in the same file. = When I source it, I get the following error message:

Error in match.call(fun, fcall) :=20
  unused argument(s) (x =3D "Molecule", y =3D "Molecule")

I can't see what's wrong in my method definition. Can anyone help me = with this?

J

Dr James Foadi PhD
Membrane Protein Laboratory (MPL)
Diamond Light Source Ltd
Diamond House
Harewell Science and Innovation Campus
Chilton, Didcot

Oxfordshire OX11 0DE

Email : james.foadi_at_diamond.ac.uk
Alt Email: j.foadi_at_imperial.ac.uk

-- 
This e-mail and any attachments may contain confidential...{{dropped:16}}

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 07 Jul 2010 - 15:19:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 07 Jul 2010 - 15:20:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive