Hi again List:

This time I have the following:
> setClass("dog",representation(breed="numeric"))
[1] "dog"
> woof <- function(x=1:10) {
+ if(!is.numeric(x))stop("Must have numeric data")
+ y <- new("dog",breed=x)
+ return(y)
+ }
> setMethod("plot","dog",
+ function(x,y,...) {
+ plot(x@breed,col="blue",type="l")
+ }
+ )
Creating a new generic function for "plot" in ".GlobalEnv"
[1] "plot"
>

My question then is: how do I create a package such that it contains the
class dog, the function woof, and the method dog for plot, please?

Thank you

        [[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