[R] setClass confusion
David Winsemius
dwinsemius at comcast.net
Fri Jul 5 01:30:10 CEST 2013
On Jul 3, 2013, at 4:54 PM, Erin Hodgess wrote:
> Dear R People:
>
>
> I am experimenting with S4 classes and methods but am having trouble with
> setting up a class.
>
> Here is an example:
>
>> buzz <- setClass("buzz",slots=c(x="matrix"),
> + validity <- function(object) {
> + if(is.matrix(object)==FALSE)stop("Input must be a matrix")
> + TRUE
> + })
> Error in setClass("buzz", slots = c(x = "matrix"), validity <-
> function(object) { :
> Argument "representation" cannot be used if argument "slots" is supplied
>>
>
> I know that there is something simple that I'm just not seeing.
If you take the validity argument out it doesnot throw an error and the help page for setClass refers you to ?validObject for details.
>
> This is R-3.0.1 for Windows.
> Thanks for any help.
>
> Sincerely,
> Erin
>
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list