Re: [R] classes and methods

2009-03-20 Thread Wacek Kusnierczyk
mtmor...@fhcrc.org wrote: >> setClass("foo",representation(x="numeric")) > > This creates an *S4* class which HAS A 'slot' x that is of type numeric. > >>> setMethod("plot","foo",function(x,y,...)boxplot(x,...)) >>> x <- rnorm(100) >>> class(x) <- "foo" > > uh oh, this is creating an *S3* class tha

Re: [R] classes and methods

2009-03-19 Thread mtmorgan
Hi Edna -- Quoting Edna Bell : I have put together a test class and methods setClass("foo",representation(x="numeric")) [1] "foo" This creates an *S4* class which HAS A 'slot' x that is of type numeric. setMethod("plot","foo",function(x,y,...)boxplot(x,...)) [1] "plot" x <- rnorm(100)

[R] classes and methods

2009-03-19 Thread Edna Bell
I have put together a test class and methods > setClass("foo",representation(x="numeric")) [1] "foo" > setMethod("plot","foo",function(x,y,...)boxplot(x,...)) [1] "plot" > x <- rnorm(100) > class(x) <- "foo" > plot(x) > y <- new("foo",x=rnorm(50)) > class(y) [1] "foo" My question is: should I