Re: [R] R design (was "Variable passed to function not used in function in select)

From: Ben Bolker <bolker_at_ufl.edu>
Date: Tue, 11 Nov 2008 21:42:09 +0000 (UTC)

Rolf Turner <r.turner <at> auckland.ac.nz> writes:

[snip]

> 

> But I think that the best approach would be to include a warning in
> the documentation of subset, to the effect: ``There are subtle and
> difficult issues involved in the use of this function. If you don't
> understand them, don't mess with it.''
options(enable.expert.use=TRUE) ? (We could couple this with a "tainting" mechanism like that for proprietary modules in the Linux kernel -- in our case it
would disallow posting on the topic to r-help ...)  

> Others have pointed out in this thread that one does not *have* to use
> subset() --- anything it can do can be done in other ways. Like those
> who pointed this out, I myself have never used subset(), never felt I
> had to, and never felt any the worse for not having done so.

  I have been encouraging my students to use subset() because in many cases it lets them work on a higher level of abstraction -- "I want to select the following variables/cases" rather than "I want to do logical indexing on this data frame". Sooner or later one has to get down to the lower level of abstraction, but it's nice to be able to work at the higher level when one doesn't *need* to get all dirty and worry about the details ... it's like the difference between

sqrt(outer(data$x,data$x,"-")^2+outer(data$y,data$y,"-")^2)

and

as.matrix(dist(data))

  Sometime soon when I have the time and energy I will start campaigning for an additional "drop" argument to subset that does what one expects (!!??) with subsetted factor variables ...

  cheers
    Ben Bolker



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 11 Nov 2008 - 21:46:03 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 Tue 11 Nov 2008 - 23:30:24 GMT.

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

list of date sections of archive