and help(merge) if you want to to it like a database join
• 0 views
•
link
How can I read in two tab delimited files and map them together by one common column(protein)?
protein_pathway.txt
Pathway Protein
Binding and Uptake of Ligands by Scavenger Receptors P69905
Erythrocytes take up carbon dioxide and release oxygen P69905
Metabolism P69905
Amyloids P02647
Metabolism P02647
Hemostasis P68871
protein_gene.txt
Gene Protein
Fabp3 P11404
HBA1 P69905
APOA1 P02647
Hbb-b1 P02088
HBB P68871
Hba P01942
datafile1 <- read.csv("c:/gene.csv", header=T, sep=",")
datafile2 <- read.csv("c:/pathway.csv", header=T, sep=",")
dim(datafile1)
dim(datafile2)
datafile <- rbind(datafile1,datafile2)
dim(datafile)
write.csv(datafile,"c:/datafile.csv")
This only gives me the merged (appended one). How can map by a common column protein here?
help(match)
Merge them by using http://merge-csv.com. You can remove dupcliate headers also.
Use merge:
datafile <- merge(datafile1, datafile2)
Log in to answer this question.