[Rd] import question

From: Ben Bolker <bbolker_at_gmail.com>
Date: Wed, 23 Mar 2011 19:44:52 -0400

  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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 23 Mar 2011 - 23:50:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Mar 2011 - 04:40:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive