##provided both dataframes have the same number/names of rows in a
different order;
df1 = df1[rownames(df1)%in%rownames(df2), ]
df1 = df[rownames(df2), ]
merged_df = cbind (df1, df2)

##if dataframes have different number of rows
merged_df = merge (df1, df2, by = 0, all = TRUE)


On Wed, Jul 3, 2013 at 7:59 AM, chris Jhon <cjhon217@gmail.com> wrote:

> Dear All,
>
> I have two data frames like this
>
> Gene expression_normal
> gene1 0
> gene2 100
> .
> .
> .
>
>
> data frame 2
>
> Gene expression_cancer
> gene2 4
> gene1 29
> gene3 1
> ..
> .
>
> .
>
> I would like to merge the tables that the data frame has each gene and the
> expression value of normal and cancer such that
>
> Gene Exp_normal exp_cancer
> Gene1 0       29
> gene2  100   4
> gene3  1      0
> .
> .
>
> .
>
> how to do this in R, i tried merge but i found significant increase in
> number of rows.
> Any help is appreciated
>
>
> Best Regards,
> Chris
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>



-- 
Alyaa Mahmoud

"Love all, trust a few, do wrong to none"- Shakespeare

	[[alternative HTML version deleted]]

