Re: [R] Variable passed to function not used in function in select=... in subset

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 10 Nov 2008 17:08:41 -0500

On Mon, Nov 10, 2008 at 4:17 PM, Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no> wrote:
> Gabor Grothendieck wrote:
>> Certainly this has been recognized as a potential problem:
>>
>> http://developer.r-project.org/nonstandard-eval.pdf
>>
>> however, it is convenient when you are performing
>> an analysis and entering commands directly as opposed
>> to writing a program although possibly the potential ambiguities
>> overshadow the convenience.
>>
>
> in most cases, i do not see why one could not use a string literal
> passed by value instead of having an expression deparsed within the
> function, which may lead to confusing behaviour. this would give much
> more consistent and predictable code. this has nothing to do with the
> evaluation mechanism, which can still be lazy.
>
>
>
> in the case of subset, i do not really see how this design might be
> helpful, but it's easy to see how it can be harmful, examples have just

I think the thrust of your comments were already made by reference.

Regarding the convenience it occurs in expressions like this:

   iris2 <- subset(iris, select = - Species)

to create a data frame without the Species column.

Perhaps this would have better been done by allowing an optional formula for the select clause:

   iris2 <- subset(iris, select = ~ - Species)

but I think R is stuck with what it has due to compatibility and the large base of users yet its still possible to add functions in packages or new functions to R so a new variant of subset would be possible in which case one could decide to use the new function in place of the old one.



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 Mon 10 Nov 2008 - 22:17:31 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 - 09:30:23 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