[Rd] S4 and connection slot [Sec=Unclassified]

Troy Robertson Troy.Robertson at aad.gov.au
Mon Jun 29 06:39:55 CEST 2009


Right you are Martin,

When you simplify things right down your code below works.

I had kept getting the error below:

Error in validObject(.Object) :
  invalid class "KrillEnvironment" object: class for slot "datafileConn" ("file")

But now realise that it is when the class extends '.environment' and passes through the .xData slot:
--------------------------------
setClass("Element",representation=representation(datafileConn="file"), contains=".environment")

setMethod("initialize", "Element",
  function(.Object,.xData=new.env(parent=emptyenv())) {
    .Object <- callNextMethod(.Object, .xData=.xData)
    return(.Object)
  }
)

s <- new("Element")
--------------------------------

Not sure why that changes things though?

Troy

> -----Original Message-----
> From: Martin Morgan [mailto:mtmorgan at fhcrc.org]
> Sent: Monday, 29 June 2009 2:21 PM
> To: Troy Robertson
> Subject: Re: [Rd] S4 and connection slot [Sec=Unclassified]
>
> Troy Robertson wrote:
> > Hi all,
> >
> >
> >
> > I am having a problem trying to declare a slot representation to hold a
> file connection.
> >
> > With V2.8.0 I had been using:
> >
> >
> >
> > setClass("Element",
> >
> >     representation(
> >
> >         [other slots removed],
> >
> >         datafileConn    = setOldClass(c("file","connection"))
> >
> >     )
> >
> > )
> >
>
> I think
>
> setOldClass(c("file", "connection"))
>
> setClass("Element",
>          representation=representation(datafileConn="file"))
>
> getClass("file")
> getClass("Element")
>
> but I don't usually use S3 classes so I'm not sure...
>
> Martin
>
> >
> >
> > This resulted in a warning but still ran okay.
> >
> >
> >
> > No however with V2.9.0 I am getting an error:
> >
> >
> >
> > Error in representation(state = "list", initialState = "list", polygons
> = "list",  :
> >
> >   element 12 of the representation was not a single character string
> >
> >
> >
> > How can I declare a slot of the appropriate class?  The strings
> "connection", "file" fail.
> >
> >
> >
> > Troy
> >
> >
> >
> >
> >
> > Troy Robertson
> >
> > Database and Computing Support Provider
> >
> > Southern Ocean Ecosystems, ERM/Fish
> >
> > Australian Antarctic Division
> >
> > Channel Highway, Kingston 7050
> >
> > PH: 03 62323571
> >
> > Troy.Robertson at aad.gov.au
> >
> >
> >
> >
> >
> __________________________________________________________________________
> _
> >
> >     Australian Antarctic Division - Commonwealth of Australia
> > IMPORTANT: This transmission is intended for the addressee only. If you
> are not the
> > intended recipient, you are notified that use or dissemination of this
> communication is
> > strictly prohibited by Commonwealth law. If you have received this
> transmission in error,
> > please notify the sender immediately by e-mail or by telephoning +61 3
> 6232 3209 and
> > DELETE the message.
> >         Visit our web site at http://www.antarctica.gov.au/
> >
> __________________________________________________________________________
> _
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel

___________________________________________________________________________

    Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
        Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________



More information about the R-devel mailing list