0

I have two csv data X and Y

X - Is a Master Data with columns (id, name, dept)

Y- Kind of reference Data with columns (dept, fees)

X.csv
id  name    dept
1   a       IT
2   b       CS
3   ab      Mech
4   bc      IT
5   af      Mech
6   Hg      CS

Y.csv
dept    fees
IT      1111
CS      20
Mech    100

I want output like below - In both the CSV 'dept' column is common with help of that, we have to combine this two data set and create single data set with these columns (id, name, dept, fees)

XY.csv
id  name    dept    fees
1   a       IT      1111
2   b       CS      20
3   ab      Mech    100
4   bc      IT      1111
5   af      Mech    100
6   Hg      CS      20

I tried below code, but ended up in error- I dont know how to solve this.

> m=merge(X,Y,by="c")
Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column
Jaap
  • 81,064
  • 34
  • 182
  • 193
Teja R
  • 131
  • 3
  • 12
  • 1
    The error indicates clearly that "by" should be a column name. Your code will work with `by="dept"`. FYI this kind of transformation is called a join and you can find lots of resources with this keyword + "R". – asachet Apr 18 '17 at 12:20
  • Thanks guys, got the answer – Teja R Apr 18 '17 at 12:40

0 Answers0