-1

I'm trying to merge between two data frames in r. The first data frame contains internal ID and relevant data. The second dataframe contains internal ID, external ID and some irrelevant columns. I want to add the external ID to the first/main data frame and r is giving me the following error:

Error in fix.by(by.y, y) : 'by' must specify a uniquely valid column

the command I use is

Decisions=merge(Decisions,Companies[,c("mispar_rasham")],
                by.x = "mispar_chevra" , by.y ="mispar.chevra", all.x = TRUE)

I tried to use the same command before with other secondary data frame and it worked well.

I read about the command and I made sure both columns are defined the same (as.numeric) and both tables are defined as data frames.

I also tried all the answers I found in google for this problem. I'm kind of new with programming I guess I'm missing something basic.

João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109
  • Please share a sample of the data you are using so your error can be properly reproduced. See some guidelines here: – Juan Bosco Jan 29 '18 at 16:27

1 Answers1

1

the merge function is as follows.

merge(xDataSet, yDataset)

so when you use:

Decisions=merge(Decisions,Companies[,c("mispar_rasham")],
                by.x = "mispar_chevra" , by.y ="mispar.chevra", all.x = TRUE)

it should probably be:

Decisions=merge(Decisions,Companies[,c("mispar_rasham")],
                by.y = "mispar_rasham" , by.x ="mispar.chevra", all.x = TRUE)
DataTx
  • 1,839
  • 3
  • 26
  • 49
  • I forgot to mention the coulmn in y. the right code is: Decisions=merge(Decisions,Companies[,c("mispar_chevra","mispar_rasham")], by.y = "mispar_rasham" , by.x ="mispar.chevra", all.x = TRUE) thanks mate! – Ron Rabi Jan 29 '18 at 16:35
  • Yes, which is what I put – DataTx Jan 29 '18 at 17:52