0

I have two separate files of data, and I need to merge them. There is one column that is common to both these files. The first file is tha data itself, and the second file is a list of info that I want to display in the first file.

So I made the common column the last column of the first file and the first column of the second file and tried a left join in the hope that it would display all info from the second file. It gives me a new file where the column name of the second file are there but all other cells are filled with NA. I also tried several other things I found online, it always lead to either all cells of the second file filled with NA or occasionally it retains some info but never all.

I have no idea if this is clear and I am quite new to R so this might be a stupid problem to have, but I can't seem to figure out what I am doing wrong. Does anybody have some idea of what I can do?

elge
  • 1
  • Welcome to SO, elge! Questions on SO (especially in R) do much better if they are reproducible and self-contained. By that I mean including attempted code (please be explicit about non-base packages), sample representative data (perhaps via `dput(head(x))` or building data programmatically (e.g., `data.frame(...)`), possibly stochastically), perhaps actual output (with verbatim errors/warnings) versus intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Apr 12 '23 at 10:21
  • This might be a duplicate of one of: (merge/join) https://stackoverflow.com/q/1299871/3358272, https://stackoverflow.com/q/5706437/3358272, (data.table) https://stackoverflow.com/q/34598139/3358272. If I'm misunderstanding, it might be `cbind` (column-binding). or `rbind` (row-binding), though I'm thinking more the links above. – r2evans Apr 12 '23 at 10:22

0 Answers0