[R] For help in R coding

Bansal, Vikas vikas.bansal at kcl.ac.uk
Tue Jul 5 17:48:48 CEST 2011


Hi

I sorted out a little bit-

I am using this code-
vi=(m1 <- merge(blaa, daf, by.x = "V2", by.y = "V2"))
(m2 <- merge(daf, blaa, by.x = "V2", by.y = "V2"))


results are also coming fine.
but i dont know i got another code-

stopifnot(as.character(m1[,1]) == as.character(m2[,1]),
          all.equal(m1[, -1], m2[, -1][ names(m1)[-1] ]),
          dim(merge(m1, m2, by = integer(0))) == c(36, 10))

Can you tell me what this code will do????

Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
________________________________________
From: ONKELINX, Thierry [Thierry.ONKELINX at inbo.be]
Sent: Tuesday, July 05, 2011 3:53 PM
To: Bansal, Vikas; David Winsemius
Cc: r-help at r-project.org
Subject: RE: [R] For help in R coding

Dear Vikas,

Have at look at ?merge()

Best regards,

Thierry

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> Namens Bansal, Vikas
> Verzonden: dinsdag 5 juli 2011 16:51
> Aan: David Winsemius
> CC: r-help at r-project.org
> Onderwerp: Re: [R] For help in R coding
>
> Dear all,
>
> I have one problem and did not find any solution.Please I want your help.
>
> I have two data frames and I want to concatenate them.But the thing is-
>
> two data frames are like this-
>
> V1           V2               A       C       G       T
> 10    135344109       0       0       1       0
> 10    135344110       0       1       0       0
> 10    135344111       0       0       1       0
> 10    135344112       0       0       1       0
> 10    135344113       0       0       1       0
> 10    135344114       1       0       0       0
> 10    135344115       1       0       0       0
> 10    135344116       0       0       0       1
> 10    135344117       0       1       0       0
> 10    135344118       0       0       0       1
>
> second data frame-
>
> V1           V2               A       C       G       T
> 10    135344111       1       0       1       0
> 10    135344113       0       0       1       0
> 10    135344109       0       3       1       0
> 10    135344114       1       0       0       0
> 10    145344115       1       0       0       0
> 10    135344116       1       0       0       1
> 10    132344117       0       1       0       0
> 10    135344118       0       0       0       1
> 10    135344110       0       1       0       0
>
> now i have to create a new data frame which has  insert column 3,4,5 and 6 of
> second data frame in first data frame if the value in second column is same in
> both the data frames (values in V2 column).So the output(new data frame)
> should be-
>
> V1           V2               A       C       G       T     A       C     G      T
> 10    135344109       0       0       1       0      0        3       1       0
> 10    135344110       0       1       0       0      0        1       0       0
> 10    135344111       0       0       1       0      1        0       1       0
> 10    135344113       0       0       1       0      0        0       1       0
> 10    135344114       1       0       0       0      1        0       0       0
> 10    135344116       0       0       0       1      1        0       0       1
> 10    135344118       0       0       0       1      0        0       0       1
>
> I f you see the output, second column values-
>
>              V2
>       135344109
>       135344110
>       135344111
>       135344113
>       135344114
>       135344116
>       135344118
>
> these values are common in both input dataframes.
>
>
>
>
>
>
> Thanking you,
> Warm Regards
> Vikas Bansal
> Msc Bioinformatics
> Kings College London
> ________________________________________
> From: David Winsemius [dwinsemius at comcast.net]
> Sent: Monday, July 04, 2011 12:11 AM
> To: Bansal, Vikas
> Cc: Dennis Murphy; r-help at r-project.org
> Subject: Re: [R] For help in R coding
>
> On Jul 3, 2011, at 6:10 PM, Bansal, Vikas wrote:
>
> >
> > ________________________________________
> > From: David Winsemius [dwinsemius at comcast.net]
> > Sent: Sunday, July 03, 2011 7:08 PM
>
> >>
> >
> > the code is same i just want to add a condition so that  it should
> > check that if in column 3, the character is A then make number of A
> > equal to total number of . and ,
> >
> > Should I explain better or can you please tell me which thing is not
> > clear?
>
> My second posting today had a solution.
>
>
> >
> >>
> > --
> > David.
> >>
> >>
> >>
> >> Can you please help me how to use this if condition in your coding or
> >> we can also do it by using some other condition rather than if
> >> condition?
> >>
> >
>
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list