[R] S4 plot function (Package)...

Daniel Kosztyla kossi at cs.tu-berlin.de
Tue Jan 4 13:07:31 CET 2011


Hello,

I have a problem programming 2 plot methods for 2 classes.
1. I have 2 classes. Each class has its own plot method. !!! How the 
plot,xxx-method.R -files have to look like,
so that the plot method for class 1 und plot methods for class 2 can act 
for each belonging class. Prob

My example for "plot_class1.R" for class labeled class1 (class2 
equivalent):

if (!isGeneric("plot")) {
   setGeneric("plot", function(x="class1", y="ANY", ...) 
standardGeneric("plot"), package="the_package_name");
}

setMethod("plot", signature(x="class1", y="ANY"),
   function(x, y, type="xy", method = names(x at misclass), anno="symbol", 
...)
   {
     ... #code
   }
}

#DOCS
\name{plot,class1-method}
\docType{methods}
\alias{plot}
\alias{plot,class1-method}
...


Looks it correct?
thx so far.
Dan



More information about the R-help mailing list