[R] If statement generates two outputs

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Mar 24 09:26:40 CET 2009


Berwin A Turlach wrote:
> G'day Carl,
>
> On Mon, 23 Mar 2009 20:11:19 -0400
> Carl Witthoft <carl at witthoft.com> wrote:
>
>   
>>  >From: Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no>
>>  >Date: Sun, 22 Mar 2009 22:58:49 +0100
>>
>>
>>  >just for fun, you could do this with multiassignment, e.g., using
>>  >the (highly experimental and premature!) rvalues:
>>
>>  >    source('http://miscell.googlecode.com/svn/rvalues/rvalues.r') 
>>  >if (TRUE)
>>
>>  >       c(df1, df2) := list(4:8, 9:13)
>>
>>  >    dput(df1)
>>  >    # 4:8
>>  >    dput(df2)
>>  >    # 9:13
>>
>>
>> -------
>> Now THAT's what I call an overloaded operator!   ^_^
>>     

it's not really overloaded, it's *loaded*.  if you type

    a :=  1

in an r session without defining '=', r cannot 'find such a function',
but it doesn't complain about invalid syntax.  so there is the operator,
only that it's not operational. 

>> But seriously:  can someone explain to me what's going on in the 
>> rvalues.r code? 

i think i-the-sinner'd be the right person to ask.  i'd suggest to
discuss offline, because rvalues is really an experiment, a proof of
concept, and as such may not be of interest for wider audience.  (it
might be that it will be developed into something substantial, but no
guarantees.)

vQ




More information about the R-help mailing list