R-beta: Re: S Compatibility
Bill Venables (wvenable@attunga.stats.adelaide.edu.au)
Wed, 30 Apr 1997 09:21:07 +0930
Date: Wed, 30 Apr 1997 09:21:07 +0930
Message-Id: <9704292351.AA17204@attunga.stats.adelaide.edu.au>
From: Bill Venables <wvenable@attunga.stats.adelaide.edu.au>
To: Thomas Lumley <thomas@biostat.washington.edu>
Subject: R-beta: Re: S Compatibility
In-Reply-To: <Pine.SUN.3.95.970429161857.9552D-100000@avon>
<Pine.SUN.3.95.970429161857.9552D-100000@avon>
Thomas Lumley writes:
> On Wed, 30 Apr 1997, Ross Ihaka wrote:
> >
> > Some things we almost certainly won't be changing. Scoping
> > is one of these (although I have to confess that I have made
> > the pitch to Robert that we should drop our scoping in
> > favour of the S version - he sensibly said "no").
>
> Quite right too. My favorite example is a function that I and
> several of my fellow students have at various times tried to
> write in S.
>
> jack.lm<-function(lm.obj){
> ii<-as.matrix(1:length(lm.obj$residuals))
> var(t(apply(ii,1,function(i) update(lm.obj,subset=-i)$coef)))
> }
>
> or similar things for bootstrap, weighted bootstrap, glms and
> so on. In every case people have spent hours staring at this
> code and wondering why it claims to be unable to find lm.obj.
Just to satisfy the curious - I'm not saying it is good or bad -
there is a way to do it in S, of course, namely
jack.lm <- function(lm.obj) {
ii <- matrix(1:length(lm.obj$residuals))
var(t(apply(ii, 1, function(i, obj)
update(obj, subset = -i)$coef, lm.obj)))
}
My question is, though, will this also work in R? It it intended
to remain so? Given that the S scoping rules are more
restrictive, it would be a mistake to make it impossible to write
code that is usable on both systems.
> My view on the scoping rules of R is that they aren't an
> incompatibility since most people I have talked to think that
> S scopes this way.
Are the scoping differences between R and S set out precisely and
definitively somewhere? This would be useful.
(As a complete side-issue, Brian Ripley and I have a kind of
convention: we refer to the language as "S" and the commercial
product as "S-PLUS". There is a useful distinction to be made.)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=