This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Mapping common identifiers between two files

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

merge mapping csv r

Have a look into dplyr joins. dplyr::left_join(df1, df2) keep all the rows from df1. dplyr::right_join(df1, df2) keep all the rows from df2.

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:

merge(data.frame(x = 1:3, y = 11),
      data.frame(x = 2:4, z = 22), by = "x")
#   x  y  z
# 1 2 11 22
# 2 3 11 22

See this StackOverflow post for more examples and other merging options:

0 answers

No answers yet.

Log in to answer this question.