Re: [R] Counting elements in columns

From: Dennis Murphy <djmuser_at_gmail.com>
Date: Sat, 16 Apr 2011 20:15:59 -0700

length(intersect(a, b))

On Sat, Apr 16, 2011 at 8:04 PM, Jim Silverton <jim.silverton_at_gmail.com> wrote:
> I have two columns and I want to count hwo many pairs I have of the same
> element. For example. If I have
> a = c(1,2,3,4,5)
> b= c(12, 1, 34, 2, 5, 0, 10, 100, 11)
> It should return 3 (since 1, 2 and 5 occur in both columns).
> Columns need not be of the same length.
>
> --
> Thanks,
> Jim.
>
>        [[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.
>



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. Received on Sun 17 Apr 2011 - 03:17:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 17 Apr 2011 - 06:10:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive