[R] Replacing data from one data frame to another

Gabor Grothendieck ggrothendieck at myway.com
Wed Oct 20 05:54:34 CEST 2004



Check out the merge command.

From:   Neil Leonard <nleonard at tartarus.uwa.edu.au>

Hi,

I have a data frame which contains two fields, 'prev' and 'mchnum'.

I have another data frame which also contains 'mchnum' and 'prev' and 
some other fields. The 'prev' data in this field is corrupted and I 
want to replace it with the data from the other data frame for matching 
values of 'mchnum' (which are unique). Is there an easier way of doing 
this than having two for loops and going through each field looking for 
matching values of 'mchnum' and then replacing the 'prev' value when 
they match.


Thanks
Neil




More information about the R-help mailing list