[R] The end of Matlab

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Dec 12 11:07:03 CET 2008


Duncan Murdoch wrote:
> On 12/12/2008 3:41 AM, Wacek Kusnierczyk wrote:
>>
>> but this 'general rule' is not really adhered to in r!  one example
>> already discussed here at length is subset:
>>
>> subset(data.frame(...), select=a)
>>
>> what will be selected?  column named "a", or columns named by the
>> components of the vector a?  this is an example of how you can't say
>> what an expression means in a context-independent manner.  
>
> From which you might conclude that I don't like the design of subset,
> and you'd be right.  However, I don't think this is a counterexample
> to my general rule.  In the subset function, the select argument is
> treated as an unevaluated expression, and then there are rules about
> what to do with it.  (I.e. try to look up name `a` in the data frame,
> if that fails, ...)
>
> For the requested behaviour to similarly fall within the general rule,
> we'd have to treat all indices to all kinds of things (vectors,
> matrices, dataframes, etc.) as unevaluated expressions, with special
> handling for the particular symbol `end`.  But Mike wanted an End
> function, so presumably he wanted the old behaviour of indexing, but
> to have a function whose value depended on where it was called from. 
> We do have those (e.g. the functions for examining the stack that Mike
> wanted to make use of), and they're needed for debugging and a few
> special cases, but as a general rule they should be avoided.
>
> > and this is
>> an ubiquitous problem in r.
>
> I don't think so.
>

i'd think that neither the 'evaluate' nor the 'deparse' approaches to
establishing the values of arguments are particularly rare in r.

vQ



More information about the R-help mailing list