[Rd] import question

Ben Bolker bbolker at gmail.com
Thu Mar 24 00:44:52 CET 2011


  I have been struggling all day to import a particular function/method
combination (ranef(), which extracts the random effects from a mixed
model fit) from the nlme package into another package ... so far without
success.

  The NAMESPACE for nlme contains the following lines:

export(..., ranef, ...)
S3method(ranef, lme)

  ranef is defined as a standard S3 generic,

function (object, ...)
   UseMethod("ranef")
<environment: namespace:nlme>

  I made up a minimal package, "raneftest" (which is available at
<http://www.math.mcmaster.ca/~bolker/misc/raneftest_0.001.tar.gz>)
that contains a single function, ranef.x(), which is supposed to be an
S3 method for class x ... its (trivial) definition is

ranef.x <- function(object, ...) {
   print("x")
}

the package has a NAMESPACE file:

-----------
exportPattern("^[^\\.]")

##importFrom(nlme,ranef)
import(nlme)
----------

(I've tried both import() and importFrom() -- I would prefer to use
importFrom() if I can ... I also tried importMethodsFrom(nlme,ranef) ,
but it fails -- it seems to be intended for S4 and not S3 methods?)

  The package also has a tests directory with a single file, which looks
like this:

  > library(raneftest)
  > x <- 1
  > class(x) <- "x"
  > ranef.x(x)
  [1] "x"
  > ranef(x)
  Error: could not find function "ranef"
  Execution halted

  I have read the relevant section of R-exts.pdf several times --
apologies in advance if I am doing something boneheaded.

  Does anyone have suggestions for what to try next ... ?

  cheers
    Ben Bolker



More information about the R-devel mailing list