[R] Not finding superclass in library

Charles C. Berry ccberry at ucsd.edu
Tue Feb 24 04:20:43 CET 2015


On Mon, 23 Feb 2015, Ramiro Barrantes wrote:

> Thank you for pointing this out.  I had no idea about the distinction 
> but there are some good references on the matter 
> (http://www.r-bloggers.com/packages-v-libraries-in-r/).  I am pasting 
> the corrected version below, any suggestions appreciated:

>

> I have a package that I created that defines a parent class, 
> assayObject.

>
> I created other classes that inherit from it, say assayObjectDemo. 
> Each one of those classes I wanted to make in its own directory separate 
> from where the assayObject is defined (there are reasons for that).

>
> But now if I do:
>
> library(assayObject)  #<--- where parent object is defined
> source("assayObjectDemo.R")
>
> where assayObjectDemo.R is just:
>
> setClass("assayObjectDemo",contains="assayObject")
> createDemoAssayObject <- function() {
>  df <- data.frame()
>  assay<-new(Class="assayObjectDemo")
>  assay
> }
>
> I get:
>
> Error in reconcilePropertiesAndPrototype(name, slots, prototype, superClasses,  :
>  no definition was found for superclass “assayObject” in the specification of class “assayObjectDemo”
>
> What can I do?


Start with a reproducible example. Here is one:

   library(Matrix)
   tmpf <- tempfile(fileext=".R")
   cat('setClass("MatrixDemo",contains="Matrix")',file=tmpf)
   source(tmpf)
   slotNames("MatrixDemo")

And it produces the expected output without error:

  [1] "Dim"      "Dimnames"

Since this works fine for a widely used package and fails for your
(unspecified) package, I suspect there is a problem with your package.

If I had to guess, I'd say it is a NAMESPACE issue. Be sure your
exportClasses directive is correctly formed per Section 1.5.6
"Namespaces with S4 classes and methods" of R-exts.

r-devel might be a better venue for this discussion.

HTH,

Chuck


More information about the R-help mailing list