[R] ask for help with this R quesiton

Henrique Dallazuanna wwwhsd at gmail.com
Wed Jan 27 19:20:00 CET 2010


Try this:

unique(cbind(tag, phi))[order(unique(tag)),]

On Wed, Jan 27, 2010 at 4:13 PM, song song <rprojecthelp at gmail.com> wrote:
>> question like this:
>>
>> I have data tag and phi, when tag are the same, then phi are the same. like
>> below, tag have value 1 2 3 4 and phi have value .9 .3 1 0.
>>
>> my question is, how can I get the result like
>> tag=c(1,2,3,4) and corresponding phi=c(.9,.3,1,0)
>>
>> tag   phi
>> 2    .3
>> 1    .9
>> 2    .3
>> 3    1
>> 2    .3
>> 1    .9
>> 3    1
>> 4    0
>> 1    .9
>> 2    .3
>>
>> tag=c(2,1,2,3,2,1,3,4,1,2)
>> phi=c(.3,.9,.3,1,.3,.9,1,0,.9,.3)
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list