How to merge 2 dataframes based on common column names?
1
1
Entering edit mode
5.5 years ago
vinayjrao ▴ 250

Hi,

I have two data frames, both containing the columns GeneName and logFC.

Using intersect(), I have obtained the common genes between the two. I want to know how to merge my two dataframes based on the common dataframe.

Thank you.

R • 6.9k views
ADD COMMENT
1
Entering edit mode
5.5 years ago

1. Get common column names

common_column_names <- intersect(names(dataframe_1), names(dataframe_2))

2. Use this character vector as your by parameters in the merge function.

merge(dataframe_1, dataframe_2, by=common_column_names, all.dataframe_1=TRUE)

** P.S - Your title of the question should be "How to merge 2 dataframes based on common column names?" I have edited the title.

ADD COMMENT

Login before adding your answer.

Traffic: 1824 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6