Skip to content
Back to formatted view

Raw Message

Message-ID: <2d1ebb110903192142g598e2a8elb6ea1eb559f7a8d@mail.gmail.com>
Date: 2009-03-20T04:42:35Z
From: Edna Bell
Subject: classes and methods

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 have a "foo" function which sets the class
to "foo", please?  or a sort of Validity checker, please?

Thanks,
Edna Bell