From murdoch.duncan at gmail.com  Fri Nov 25 19:37:18 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Fri, 25 Nov 2011 13:37:18 -0500
Subject: [Rd] How to deal with package conflicts
In-Reply-To: <1322241149.5806.120.camel@nemo>
References: <mailman.21.1322218808.15358.r-devel@r-project.org>	
	<1322230252.5806.15.camel@nemo> <4ECFB773.2060106@yorku.ca>
	<1322241149.5806.120.camel@nemo>
Message-ID: <4ECFE05E.9050103@gmail.com>

On 25/11/2011 12:12 PM, Terry Therneau wrote:
>   I like the idea of making the functions local, and will persue it.
> This issue has bothered me for a long time -- I had real misgivings when
> I introduced "cluster" to the package, but did not at that time see any
> way other than making it global.
>   I might make this change soon in the ridge function, since it's a good
> test case -- less likely to cause downstream troubles.
>
> Here is another possible approach:
>   Inside coxph, just before calling eval with the formula, create a new
> environment "tempenv" which consists of my handful of special functions
> (ridge, frailty, cluster, pspline) who have meaning only inside a coxph
> call, with a parent environment of the tempenv being the current
> environment of the formula. Then set the environment of the formula to
> tempenv, then eval.  Would this work?

It should.
>   Two small further questions:
> 1. Any special rules for the documentation?  We need a page for
> "cluster", but want to mark it almost like a method in the sense of
> applying only in a one context.

I would list those special functions as aliases of the coxph topic, and 
document them there.

> 2. Does one scheme or another work best for downstream functions like
> predict or model.matrix?  Duncan's idea of direct modification might
> have an advantage (?) in that the terms object would be permanently
> changed.

As long as you attach your new temporary environment to copies of the 
formula that you pass elsewhere, it should mostly work.  It may confuse 
someone who did  ls(environment(formula)) (because they'd only see your 
functions, not the user's), but I don't think that's a very common thing 
to want to do.

Duncan Murdoch



[Rd] How to deal with package conflicts
Duncan Murdoch