You can use 'cbind.data.frame' -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O
On 18/11/2007, affy snp <[EMAIL PROTECTED]> wrote: > > Sorry but one more question. After sorting the data frame, > I need to re-organzie the data frame by taking four columns > to create a new data frame (I used cbind). But why the > first two colums of the new data frame are not USER_CLONE_ID, > WELL_ID columns in the previous data frame. > > I am attaching the codes. > > Thanks a lot! > > Allen > > > > > cl<-clones.info[order(clones.info$CHROMOSOME, clones.info$KB_POSITION),] > cl[1:4,1:4] > cl2<-cbind(cl$USER_CLONE_ID,cl$WELL_ID,cl$CHROMOSOME,round(cl$KB_POSITION/1000)) > dim(cl2) > cl2[1:4,1:4]> dim(cl) > [1] 238304 6 > > cl[1:4,1:4] > USER_CLONE_ID CHROMOSOME Expr1002 KB_POSITION > 96169 SNP_A-1909444 1 792429 792429 > 208574 SNP_A-2237149 1 817376 817376 > 68192 SNP_A-4303947 1 819185 819185 > 210152 SNP_A-2236359 1 832343 832343 > > > cl2<-cbind(cl$USER_CLONE_ID,cl$WELL_ID,cl$CHROMOSOME,round(cl$KB_POSITION/1000)) > > dim(cl2) > [1] 238304 4 > > cl2[1:4,1:4] > [,1] [,2] [,3] [,4] > [1,] 43121 132913 1 792 > [2,] 149264 178012 1 817 > [3,] 237378 142083 1 819 > [4,] 149002 130012 1 832 > > > > > > > > On 11/18/07, affy snp <[EMAIL PROTECTED] > wrote: > > Thanks all of you. It works. > > > > Have a good weekend! > > > > Allen > > > > > > > > On 11/18/07, Benilton Carvalho < [EMAIL PROTECTED] > wrote: > > > actually, > > > > > > clones.info[order(clones.info$CHROMOSOME, clones.info$KB_POSITION),] > > > > > > btw, documented in the help file. > > > b > > > > > > On Nov 18, 2007, at 1:54 PM, Henrique Dallazuanna wrote: > > > > > > > clones.info[order( clones.info$CHROMOSOME),] > > > > > > > > -- > > > > Henrique Dallazuanna > > > > Curitiba-Paraná-Brasil > > > > 25° 25' 40" S 49° 16' 22" O > > > > > > > > > > > > On 18/11/2007, affy snp < [EMAIL PROTECTED]> wrote: > > > >> Dear list, > > > >> > > > >> I have a data frame (238304 rows and 6 columns). I want the data > > > >> frame > > > >> sorted by two columns in ascending order. I am showing > > > >> the first 5 rows of the data frame > > > >> > > > >>> clones.info[1:5,1:6] > > > >> USER_CLONE_ID CHROMOSOME Expr1002 KB_POSITION > Allele_A WELL_ID > > > >> 1 SNP_A-1855402 17 41419603 41419603 C rs17572851 > > > >> 2 SNP_A-4249904 17 41420045 41420045 A rs17572893 > > > >> 3 SNP_A-2174835 18 41407760 41407760 C rs17651213 > > > >> 4 SNP_A-1880271 18 41173993 41173993 A rs17563827 > > > >> 5 SNP_A-2313232 17 41169023 41169023 C rs17563787 > > > >> > > > >> Especially, I want the data frame sorted by column CHROMOSOME > > > >> first and then by KB_POSITION. Both in ascending orders. > > > >> > > > >> So after sorting, it should looks like: > > > >>> clones.info[1:5,1:6] > > > >> USER_CLONE_ID CHROMOSOME Expr1002 KB_POSITION > Allele_A WELL_ID > > > >> 1 SNP_A-2313232 17 41169023 41169023 C rs17563787 > > > >> 2 SNP_A-1855402 17 41419603 41419603 C rs17572851 > > > >> 3 SNP_A-4249904 17 41420045 41420045 A rs17572893 > > > >> 4 SNP_A-1880271 18 41173993 41173993 A rs17563827 > > > >> 5 SNP_A-2174835 18 41407760 41407760 C rs17651213 > > > >> > > > >> I looked at the R manual and found order() can be used to sort a > > > >> vector or data frame but only for one vector. Is it possible to > > > >> sort by two columns using order() or some other functions in > > > >> R? > > > >> > > > >> Thanks a lot! > > > >> Allen > > > >> > > > >> [[alternative HTML version deleted]] > > > >> > > > >> ______________________________________________ > > > >> R-help@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. > > > >> > > > > > > > > ______________________________________________ > > > > R-help@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. > > > > > > > > > ______________________________________________ R-help@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.