[R] Finding Equal Elements in Vectors

Spencer Graves spencer.graves at pdf.com
Sun Feb 27 16:23:09 CET 2005


      It depends on what you mean by that.  Consider the following two 
examples: 

 > sum((1:5)==(5:1))
[1] 1
 >
 > sum((2:1) %in%(1:6))
[1] 2
 >

      Does one of these solve your problem? 
      spencer graves

Sven C. Koehler wrote:

>Hello!
>
>I have two vectors and want to know how many of their elements are equal - 
>what's the best way to do this in R?  
>
>Best regards,
>
>Sven
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list