[R] Re : LOOPS
Dear lists, I want to construct a loop in R, but don't know how to do it. I can do it in SAS, but I prefer in R (which I am hoping I will off SAS for good soon). Could anyone help me to convert the SAS codes to equivalent R codes. Basically, the following codes were written to establish the sire gametes or phases for daughter design for one markers two alleles. Here are the SAS code: do i=1 to 744; do j=745 to 1540; m[j]=0; if sire[j]=anml[i] then do; if m1[j]=m1[i] and m2[j]=m2[i] then m[j]=0; else if m1[j]=m1[i] then m[j] =1; else if m1[j]=m2[i] then m[j==2; else if m2[j]=m1[i] then m[j]=1; else if m2[j]=m2[i] then m[j]=2; else m[j]=0; end do; end; end; Thanks Stella ___ This message, including attachments, is confidential. If you...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re : LOOPS
Thanks Peter. Basically, I am trying to establish the line of marker allele the progeny has inherited from either the sire or the dam. The progeny will share the sires but each have different dam (ie., daughter design or half-sib model). The SAS code I have written to identify the lines of inheritance are far from efficient and effective. I would think matrix or vector is the way to go, but I don't know SAS PROC IML well enough to do that nor do I have the package on my machine. Example : Sirem1m2n1n2 100 1 2 1 2 Progeny m1m2n1n2 101 3 2 1 1 So the likely sire phase (gamete) is 2 - 1 (m2 - n1). I hope it helps. Thanks again. Stella ___ This message, including attachments, is confidential. If you...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re : LOOPS
On Mon, 6 Dec 2004 13:36:37 +1300 [EMAIL PROTECTED] wrote: Dear lists, I want to construct a loop in R, but don't know how to do it. I can do it in SAS, but I prefer in R (which I am hoping I will off SAS for good soon). Could anyone help me to convert the SAS codes to equivalent R codes. Basically, the following codes were written to establish the sire gametes or phases for daughter design for one markers two alleles. Here are the SAS code: You may try this code. There may be better code from others. m-array(0, 795) #phase for ( i in 1:744) { # sire for (j in 745:1540) { # progeny if (sire[j] == anim[i] ) { #check if the progeny j is sired by animal i if (m1[j]==m1[i]m2[j]==m2[i] ) { m[j]=0; next} if ( m1[j]==m1[i]) { m[j] = 1; next} if (m1[j]==m2[i]) { m[j==2; next} . } } } do i=1 to 744; do j=745 to 1540; m[j]=0; if sire[j]=anml[i] then do; if m1[j]=m1[i] and m2[j]=m2[i] then m[j]=0; else if m1[j]=m1[i] then m[j] =1; else if m1[j]=m2[i] then m[j==2; else if m2[j]=m1[i] then m[j]=1; else if m2[j]=m2[i] then m[j]=2; else m[j]=0; end do; end; end; Thanks Stella ___ This message, including attachments, is confidential. If you...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Yuandan Zhang, PhD Animal Genetics and Breeding Unit The University of New England Armidale, NSW, Australia, 2351 E-mail: [EMAIL PROTECTED] Phone:(61) 02 6773 3786 Fax: (61) 02 6773 3266 http://agbu.une.edu.au AGBU is a joint venture of NSW Primary Industries and The University of New England to undertake genetic RD for Australia's Livestock Industries __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html