Hello,
As a follow-up to a previous question, I have a dataframe with 2 columns:
add.value code.coord
5 ABC
10 DEF
2 ABC
14 GHI
. .
. .
The code.coord are codes that represent coordinates of a larger matrix
called large.matrix. Each code (ABC, DEF, GHI) is a separate matrix of
row and column values and each set of coordinates is a different element
of a list (codes.list). What I need to do is read the dataframe above,
use the code in code.coord to access the coordinates stored in the
codes.list and add the value of add.value to the large.matrix elements
corresponding to the coordinates given by the code. The end result is the
large.matrix with the sum of all relevant add.values in particular
elements of the matrix.
I have been able to perform this task for one row and I have a feeling
I could evaluate all rows with a 'for' loop. But in the interest of time,
I would like to avoid looping through each row of the dataframe. Do you
have any ideas how to make this algorithm more efficient?
Thanks in advance,
RC
|