Hello.

I'm trying to count string data that correspond to a given
condition in two factors of the same length.

For example, I have one factor

[ 'A', 'B', 'A', 'C', 'B', 'D', 'B' ]

and another is 

[ '1', '2', '2', '3', '2', '2', '3' ]

I'd like to count the occurences of 'B' and '2' (so in my example, I should
get 2 as an answer, since there are 2 'B' that correspond to '2' in the
other factor).

I tried doing it with loops (looping on one factor for 'B', looking for
the corresponding value in the second factor, and incrementing a counter
when the corresponding value is '2'), but I didn't succeed, and I know it's
not the R-way.

Any hint or direction?

Thanks.

-- 
Fabrice DELENTE

______________________________________________
R-help@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.

Reply via email to