Merging two data frame
2
0
Entering edit mode
chris Jhon ▴ 260
@chris-jhon-5047
Last seen 10.2 years ago
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]]
Cancer Cancer • 1.7k views
ADD COMMENT
0
Entering edit mode
@steve-lianoglou-2771
Last seen 21 months ago
United States
Hi, On Tuesday, July 2, 2013, chris Jhon 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 merge will do it. Can you post the code that you used so we can help you debug it? -Steve -- Steve Lianoglou Computational Biologist Bioinformatics and Computational Biology Genentech [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
Alyaa Mahmoud ▴ 440
@alyaa-mahmoud-4670
Last seen 4.7 years ago
##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]]
ADD COMMENT
0
Entering edit mode
Hi Alyaa, Thank you very much,it works now. Previously i did : merge(df1,df2) but i realized an increase in the size of merged data frame. On Wed, Jul 3, 2013 at 2:05 PM, Alyaa Mahmoud <alyamahmoud@gmail.com> wrote: > ##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]]
ADD REPLY

Login before adding your answer.

Traffic: 638 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