[R] If statement generates two outputs

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Sun Mar 22 22:58:49 CET 2009


jimdare wrote:
> Thanks very much 
>
>   

you're welcome.

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

vQ

>
> Wacek Kusnierczyk wrote:
>   
>> jimdare wrote:
>>     
>>> Hi,
>>>
>>> How do I tell an if statement to generate two seperate outputs.
>>>
>>> E.g  If X>5 I want to create df1 and df2:
>>>
>>> if (X>5) {df1<-c(4,5,6,7,8) AND df2<-c(9,10,11,12,13)}
>>>   
>>>       
>> almost there:
>>
>>     if (X>5) {df1<-c(4,5,6,7,8); df2<-c(9,10,11,12,13)}
>>
>> vQ
>>
>> ______________________________________________
>>




More information about the R-help mailing list