[R] Are any values in one list contained within a second list
David Winsemius
dwinsemius at comcast.net
Sun Jun 13 20:26:23 CEST 2010
On Jun 13, 2010, at 2:17 PM, GL wrote:
>
> Silly question, but, can I test to see if any value of list a is
> contained in
> list b without doing a loop? A loop is easy enough, but wanted to
> see if
> there was a cleaner way. By way of example:
>
> List 1: a, b, c, d, e, f, g
>
> List 2: z, y, x, w, v, u, b
>
> Return true, since both lists contain b
>
> List 1: a, b, c, d, e, f, g
>
> List 2: z, y, x, w, v, u, t
>
> Return false, since the lists have no mutual values
length(intersect(List_1, List_2)) > 0
>
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list