[R] eval and as.name

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Feb 6 00:42:35 CET 2009


Marie Sivertsen wrote:
> Hi,
>
> Why do you use the equals sign for assignment instead of the arrow, is this
> equal?
>
>   

equal?  you mean equivalent?  mostly, yes.  briefly, this is why:

1. a copy-over from other programming languages;
2. to avoid learning yet another operator;
3. after having learned the other operator, to avoid that ugly operator;
4. after an r guru complained here about people using this instead of
that, to annoy him.

hilsen,
vQ


> Mvh.
> Marie
>
> On Thu, Feb 5, 2009 at 11:59 PM, Wacek Kusnierczyk <
> Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
>
>   
>> you may want to avoid this sort of indirection by using lists with named
>> components:
>>
>> d = list(a=c(1,3,5,7), b=c(2,4,6,8))
>> sum(unlist(d))
>> with(d, sum(a+b))
>> sum(d[['a']], d[['b']])
>> sum(sapply(n, function(v) d[[v]]))
>>
>> and so on.
>>
>> vQ
>>
>> ______________________________________________
>> 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.
>>
>>




More information about the R-help mailing list