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

This error shows up on run, what possible fix can I do? Im using R Language

code:

library(dplyr)
library(readxl)

# read in data files
Salesman <- read_excel("Salesman.xlsx", skip=1)

names(Salesman)

names(Salesman) <- make.names(names(Salesman))
names(Salesman)

#combine data sets
  combined <- merge(SalesmanName,TotalSales,Commission, by.x="SalesmanNumber", by.y="SalesmanNumber.Temp")

# save as csv
write.csv(combined, file="Temporary.xlsx", row.names=FALSE)

Solution to the merging problem

jpsmith
  • 11,023
  • 5
  • 15
  • 36
FJV26
  • 11
  • 1
  • Its hard to know since you have not provided data, but if `SalesmanName`, `Totalsales`, and `Commission` are three separate datasets, you cannot merge them all in the same `merge` statement. Try merging two then merging the third to that - ie, `x <- merge(A, B, by = "id"); xx <- merge(x, C, by = "id")` – jpsmith Dec 07 '22 at 15:01
  • After providing your code, I'd agree with jpsmith that the mistake is you're trying to join three tables when `merge` only allows you to join two. You could call `merge` twice, or see this answer for some alternatives: https://stackoverflow.com/questions/8091303/simultaneously-merge-multiple-data-frames-in-a-list – Harrison Jones Dec 07 '22 at 16:18

0 Answers0