Message-ID: <51D4BCAA.7030404@gmail.com>
Date: 2013-07-04T00:07:06Z
From: Duncan Murdoch
Subject: setClass confusion
In-Reply-To: <CACxE24mnKwt4kyfHoCX+MSj3P9J0czhEbL90faDXPeEpHMLYNA@mail.gmail.com>
On 13-07-03 7: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.
Since you used <-, your third argument uses the positional name
"representation", not "validity", which is presumably what you intended.
Duncan Murdoch