Skip to content
Prev 161655 / 398500 Next

R design (was "Variable passed to function not used in function in select)

On 11/11/2008 10:28 AM, Terry Therneau wrote:
There's another major use for this:  model formulas.  I like to be able 
to write lm(y ~ ., data=df), and I'd really hate to have to evaluate all 
the terms in a model formula explicitly.
I don't know your definition of "completely functional", but I don't 
think S and R have ever been.  It has always been possible to refer to 
non-local variables within a function (and their meaning is different 
between S and R, but I think R tends to be a bit more functional in 
this), to make super-assignments, to do lots of things that have side 
effects.
I don't know what you mean here.  Are you talking about recent changes? 
  (Which ones?)  Or are you talking about older things, like namespaces? 
  Or closures, which have been in R from the beginning (and which are 
part of why I'd call it more functional than S)?


I am not sure
R allows a lot of flexibility in how arguments are handled, and there's 
been some experimentation with different variations.  Remember that R is 
partly a laboratory in which people are trying to invent new ways of 
doing statistical computing, and also remember that R (including its 
contributed packages) has hundreds of authors, not all of whom agree on 
the best way to do things.  The benefit of this is that more stuff gets 
done:  I'm not forced to adopt your ideas of The Right Way to Do Things, 
so I can get down to coding in the way I like. The disadvantage is that 
things can be inconsistent, so people are forced to read the 
documentation, and the documentation is always imperfect.
If I'm not mistaken, you are still an S user as well as an R user, and 
  this is a bit of a disadvantage:  at a fundamental level, they are 
different languages, though they look superficially similar.  I haven't 
used S in quite a few years, so I expect I'd be stumped by the results I 
got there in a lot of cases.  I think that in the main R is a simpler, 
easier language to understand, but there are certainly bits and pieces 
of it where it is not easy.
I think we can discuss what's good and what's bad about the language 
without bringing out the guns or insults.

Duncan Murdoch