[R] Finding values in one column and

Berend Hasselman bhh at xs4all.nl
Wed Nov 28 09:05:11 CET 2012


On 28-11-2012, at 08:00, Berend Hasselman wrote:

> .....
>> I'd like to have R find the data.b$ID in data.a$ID and insert the
>> corresponding data.a$valueA and data.a$valueB into the appropriate
>> columns in data.b.
>> 
>> How can I do this?
> 
> 
> data.b <- data.a[which(data.a$ID %in% data.b$ID), ]

Of simpler (which is not needed)

data.b <- data.a[data.a$ID %in% data.b$ID, ]

and if required followed by

row.names(data.b) <- NULL

Berend




More information about the R-help mailing list