Message-ID: <20110423033148.159284t7hmfpxx1w@webmail.pdx.edu>
Date: 2011-04-23T10:31:48Z
From: xueke at pdx.edu
Subject: simple loop questions
Hi all,
I am trying to write a loop to return the matched index for a column
of values. Here is an simple example of this,
A B
0 5
1 2
2 2
3 4
4 1
5 4
6 2
In this case, A is an index column for B. Now I have this new column C
with just two values of 2 and 4. I want to match column C with column
B, and return the matched indexes. So what I desire is to return:
[1] 1 2 6
[2] 3 5
Since value 2 corresponds to indexes 1,2,6, and 4 corresponds to indexes 3,5.
Is there any way to write a loop to have this done? Thank you for the help.
Xueke