[R] using a value in a column to "lookup" data in a certian column of a dataset?

r user ruser2006 at yahoo.com
Wed Mar 15 00:59:17 CET 2006


I have a dataset with 20 columns and ~600,000 rows.

Column 1 has a number from 2-19.  This number tells
me, for each row, which column has the “applicable”
data.  (i.e. the data that I wish to use for each
individual row)

I want to create a vector that contains the data from
the value in column 1.

e.g. 
If column 1, row 1, has a value of “6”, I want to
obtain the value in column 6, row1.

If column1, row 2, has value of “2”, I want to obtain
the value in column 2, row2. etc


I have created a for next loop to do this, but am
looking for a more efficient manner.

Thanks.




More information about the R-help mailing list