[R] Clever way to match two lists

Noah Silverman noahsilverman at ucla.edu
Fri Mar 22 01:57:50 CET 2013


Hello,

I have a large data.frame of 80,000 rows where each row is a record.  Each record is indexed by a unique ID in the first column.

I need to update values for a column for *some* of the records.  I was given a data.frame with about 10,000 rows and two columns.  The first is the record ID, the second is the new values.

The slow way to do this is to loop through the new data (10,000 rows) and update the value in the corresponding master data.frame.  However this will be painfully slow.  

Does anyone have a clever way to shortcut the process.  In English, what I want to do is, "For each row in the update list, lookup the corresponding ID in the master data frame and update the value."


Ideas?


--
Noah Silverman, M.S.
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095



More information about the R-help mailing list