OK – so I have a data frame in R that looks pretty much like this:
id age v1 v2 ...
12345 31
12345 32
12345 32
I’d like to be able to look at all the IDs in this DF, and set all values of age mapped to a particular ID to the first (or lowest, in this case, as a consequence of how the DF is ordered) value of age corresponding to that ID. So the example above would become
id age v1 v2 ...
12345 31
12345 31
12345 31
I have a feeling that this could be done with plyr (or similar), although my brain’s fried right now, and I realise perhaps that might not be the best way to go about it, nor might it be the most straightforward. Any suggestions? TIA.
You’re right, plyr will get the job done.