Skip to content
Prev 273290 / 398506 Next

Matching two datasets and updating values

Hi
and
What about merge?

a<-data.frame(category, cat_val)
b<-data.frame(cust, cust_category)
merge(a,b, by.x="category", by.y="cust_category")
   category cat_val    cust
1         A    0.54  cust_3
2         A    0.54  cust_4
3         A    0.54  cust_5
4         A    0.54  cust_2
5         B    0.40  cust_8
6         B    0.40  cust_9
7         C    0.10  cust_1
8         C    0.10  cust_6
9         D    0.25  cust_7
10        D    0.25 cust_10


Regards
Petr
http://www.R-project.org/posting-guide.html