Entering edit mode
6.0 years ago
mohammedtoufiq91
▴
270
Hi,
I have two different *.csv files with different number of rows and columns. Based the the merge function I was able to combine both the files based on mapping on the ProbeID column (common between both the files) and save all the data in a output file. However, I notice that even the unmapped rows are getting saved in the output file. I am only interested in the mapped IDs common between the two files. Please assist me with this.
File_1 has 33298 ProbeIDs
File_2 has 41270 ProbeIDs
Combined file has 41270 ProbeIDs
Combined<- merge(File_1, File_2, by="ProbeID")
Thank you,
Toufiq
Have a look into
dplyrjoins.dplyr::left_join(df1, df2)keep all the rows fromdf1.dplyr::right_join(df1, df2)keep all the rows fromdf2.Provide reproducible example input and expected output. Your code looks fine and should only return matching rows that have common
"ProbeID"s in both files, test this example:See this StackOverflow post for more examples and other merging options: