On 22.02.2011 09:15, Laura Smith wrote:
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?
Copy the stuff from above in a file in your package's R directory?
Uwe
Thank you
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.
______________________________________________
[email protected] 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.