[Rd] Defining a method in two packages
Terry Therneau
therneau at mayo.edu
Fri Mar 5 17:47:57 CET 2010
The coxme package has a ranef() method, as does lme4. I'm having
trouble getting them to play together, as shown below. (The particular
model in the example isn't defensible, but uses a standard data set.)
The problem is that most of the time only one of lme4 or coxme will be
loaded, so each needs to define the basic ranef function as well as a
method for it. But when loaded together the last one wins. The coxme
object is an S3 class BTW. (Suggestions to convert it to S4 will not be
well recieved -- but that's a different and unnecessary thread.)
Odds are that this has a simple solution which I have missed.
Terry Therneau
tmt935% R --vanilla
R version 2.10.0 (2009-10-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(coxme)
Loading required package: survival
Loading required package: splines
Loading required package: bdsmatrix
> fit <- coxme(Surv(time, status) ~ age + (1|ph.ecog), lung)
> ranef(fit)
$ph.ecog
Intercept
0.1592346
> library(lme4)
Loading required package: Matrix
Loading required package: lattice
Attaching package: 'lme4'
The following object(s) are masked from package:coxme :
fixef,
ranef
> ranef(fit)
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "ranef", for signature
"coxme"
> q()
More information about the R-devel
mailing list