I'm trying to merge rows of a data set by using the mean operator. Basically, I want to convert data set 1 into data set 2 (see below)
1. ID MEASUREMENT 2. ID MEASURE
A 20 A 22.5
B 30 B 30
A 25 .
. .
. .
How can I do this on R?
Note that in contrast to the example I have given here, my data set is really large and I can't look through the data set, group rows according to their id's then find colMeans.
My thoughts are to order the dataset, separate the measures for each id, then find each mean and regroup the data. However, this will be very time consuming. I would really appreciate if someone can assist me with a direct code or even a for loop.