Dear Elisa, Try this: el<- matrix(1:100,ncol=20) ?set.seed(25) ?el1<- matrix(sample(1:100,20,replace=TRUE),ncol=1) In the example you showed, there were no column names.? ?list(el[,sort(el1)[1:3]],sort(el1,index.return=TRUE)$ix[1:3]) #[[1]] ?# ?? [,1] [,2] [,3] #[1,]?? 31?? 61?? 71 #[2,]?? 32?? 62?? 72 #[3,]?? 33?? 63?? 73 #[4,]?? 34?? 64?? 74 #[5,]?? 35?? 65?? 75 # #[[2]] #[1] 9 5 3 A.K. ________________________________ From: eliza botto <eliza_botto at hotmail.com> To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> Sent: Thursday, April 25, 2013 9:54 AM Subject: connecting matrices Dear Arun, [text file contains the exact format] Although the last codes were absolutely correct and worked the way i want them to. I have an additional cover-up question.? Suppose i have a matrix "el"....... here i show you only some part of that matrix so that codes can work faster.>el? ? ?[,595586] [,595587] [,595588] [,595589] [,595590] [,595591] [,595592] [,595593] [,595594] [,595595] [,595596] [,595597] [,595598] [,595599] [,595600] [,595601] [1,] ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 [2,] ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 ? ? ? ?61 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 [3,] ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 ? ? ? ?61 ? ? ? ?61 ? ? ? ?62 ? ? ? ?61 ? ? ? ?61 ? ? ? ?62 ? ? ? ?62 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?59 [4,] ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?62 ? ? ? ?63 ? ? ? ?63 ? ? ? ?62 ? ? ? ?63 ? ? ? ?63 ? ? ? ?63 ? ? ? ?59 ? ? ? ?60 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?60 ? ? ?[,595602] [,595603] [,595604] [,595605] [,595606] [,595607] [,595608] [,595609] [,595610] [,595611] [,595612] [,595613] [,595614] [,595615] [,595616] [,595617] [1,] ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 [2,] ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 [3,] ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 ? ? ? ?61 ? ? ? ?61 ? ? ? ?62 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 [4,] ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?62 ? ? ? ?63 ? ? ? ?63 ? ? ? ?60 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 In connection to this matrix, there is another matrix which contains coordination values for each of the column of matrix "el">el1[595586,] ? 5.67 ?? [595587,] ? 55.90 ?? [595588,] ? 515 ?? [595589,] ? 755 ?? [595590,] ? 955 ?? [595591,] ? 5.95 ?? [595592,] ? 575 ?? [595593,] ? 505 ?? [595594,] ? 505 ?? [595595,] ? 515 ?? [595596,] ? 5612 ?? [595597,] ? 506 ?? [595598,] ? 576 ?? [595599,] ? 5126 ?? [595600,] ? 5216 ?? [595601,] ? 5666 ?? [595602,] ? 526 ?? [595603,] ? 5.6 ?? [595604,] ? 156 ?? [595605,] ? 4556 ?? [595606,] ? 5556 ?? [595607,] ? 1256 ?? [595608,] ? 1256 ?? [595609,] ? 8756 ?? [595610,] ? 5906 ?? [595611,] ? 789 ?? [595612,] ? 5006 ?? [595613,] ? 1256 ?? [595614,] ? 3356 ?? [595615,] ? 7756 ?? [595616,] ? 4456 ?? [595617,] ? 3356 ?? What i want in the end is a list of two elemens containing the 10 column of "el" which have the lowest values in matrix "el1". More precisely [[1]] [,595603][,595586][595591,] 565555 575959 596062 626163 [[2]] 5.65.675.95 is it possible to carry out such operation?? thanks for your help Elisa? ? ?
HI Elisa, I guess there is a mistake. Check whether this is what you wanted. indx<-sort(el1,index.return=TRUE)$ix[1:3] list(el[,indx],indx) #[[1]] ?# ?? [,1] [,2] [,3] #[1,]?? 41?? 21?? 11 #[2,]?? 42?? 22?? 12 #[3,]?? 43?? 23?? 13 #[4,]?? 44?? 24?? 14 #[5,]?? 45?? 25?? 15 # #[[2]] #[1] 9 5 3 A.K. ----- Original Message ----- From: arun <smartpink111 at yahoo.com> To: eliza botto <eliza_botto at hotmail.com> Cc: R help <r-help at r-project.org> Sent: Thursday, April 25, 2013 10:09 AM Subject: Re: connecting matrices Dear Elisa, Try this: el<- matrix(1:100,ncol=20) ?set.seed(25) ?el1<- matrix(sample(1:100,20,replace=TRUE),ncol=1) In the example you showed, there were no column names.? ?list(el[,sort(el1)[1:3]],sort(el1,index.return=TRUE)$ix[1:3]) #[[1]] ?# ?? [,1] [,2] [,3] #[1,]?? 31?? 61?? 71 #[2,]?? 32?? 62?? 72 #[3,]?? 33?? 63?? 73 #[4,]?? 34?? 64?? 74 #[5,]?? 35?? 65?? 75 # #[[2]] #[1] 9 5 3 A.K. ________________________________ From: eliza botto <eliza_botto at hotmail.com> To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> Sent: Thursday, April 25, 2013 9:54 AM Subject: connecting matrices Dear Arun, [text file contains the exact format] Although the last codes were absolutely correct and worked the way i want them to. I have an additional cover-up question.? Suppose i have a matrix "el"....... here i show you only some part of that matrix so that codes can work faster.>el? ? ?[,595586] [,595587] [,595588] [,595589] [,595590] [,595591] [,595592] [,595593] [,595594] [,595595] [,595596] [,595597] [,595598] [,595599] [,595600] [,595601] [1,] ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?55 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 [2,] ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 ? ? ? ?61 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 [3,] ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 ? ? ? ?61 ? ? ? ?61 ? ? ? ?62 ? ? ? ?61 ? ? ? ?61 ? ? ? ?62 ? ? ? ?62 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?59 [4,] ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?62 ? ? ? ?63 ? ? ? ?63 ? ? ? ?62 ? ? ? ?63 ? ? ? ?63 ? ? ? ?63 ? ? ? ?59 ? ? ? ?60 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?60 ? ? ?[,595602] [,595603] [,595604] [,595605] [,595606] [,595607] [,595608] [,595609] [,595610] [,595611] [,595612] [,595613] [,595614] [,595615] [,595616] [,595617] [1,] ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 ? ? ? ?56 [2,] ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?57 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 ? ? ? ?58 [3,] ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 ? ? ? ?61 ? ? ? ?61 ? ? ? ?62 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?59 ? ? ? ?60 ? ? ? ?60 ? ? ? ?60 [4,] ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?62 ? ? ? ?63 ? ? ? ?63 ? ? ? ?60 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 ? ? ? ?61 ? ? ? ?62 ? ? ? ?63 In connection to this matrix, there is another matrix which contains coordination values for each of the column of matrix "el">el1[595586,] ? 5.67 ?? [595587,] ? 55.90 ?? [595588,] ? 515 ?? [595589,] ? 755 ?? [595590,] ? 955 ?? [595591,] ? 5.95 ?? [595592,] ? 575 ?? [595593,] ? 505 ?? [595594,] ? 505 ?? [595595,] ? 515 ?? [595596,] ? 5612 ?? [595597,] ? 506 ?? [595598,] ? 576 ?? [595599,] ? 5126 ?? [595600,] ? 5216 ?? [595601,] ? 5666 ?? [595602,] ? 526 ?? [595603,] ? 5.6 ?? [595604,] ? 156 ?? [595605,] ? 4556 ?? [595606,] ? 5556 ?? [595607,] ? 1256 ?? [595608,] ? 1256 ?? [595609,] ? 8756 ?? [595610,] ? 5906 ?? [595611,] ? 789 ?? [595612,] ? 5006 ?? [595613,] ? 1256 ?? [595614,] ? 3356 ?? [595615,] ? 7756 ?? [595616,] ? 4456 ?? [595617,] ? 3356 ?? What i want in the end is a list of two elemens containing the 10 column of "el" which have the lowest values in matrix "el1". More precisely [[1]] [,595603][,595586][595591,] 565555 575959 596062 626163 [[2]] 5.65.675.95 is it possible to carry out such operation?? thanks for your help Elisa? ? ?
Thanks arun,The second one look ok..thanks indeed Elisa> Date: Thu, 25 Apr 2013 07:37:25 -0700 > From: smartpink111@yahoo.com > Subject: Re: connecting matrices > To: eliza_botto@hotmail.com > CC: r-help@r-project.org > > HI Elisa, > I guess there is a mistake. > Check whether this is what you wanted. > > indx<-sort(el1,index.return=TRUE)$ix[1:3] > list(el[,indx],indx) > #[[1]] > á# áá [,1] [,2] [,3] > #[1,]áá 41áá 21áá 11 > #[2,]áá 42áá 22áá 12 > #[3,]áá 43áá 23áá 13 > #[4,]áá 44áá 24áá 14 > #[5,]áá 45áá 25áá 15 > # > #[[2]] > #[1] 9 5 3 > A.K. > > > > ----- Original Message ----- > From: arun <smartpink111@yahoo.com> > To: eliza botto <eliza_botto@hotmail.com> > Cc: R help <r-help@r-project.org> > Sent: Thursday, April 25, 2013 10:09 AM > Subject: Re: connecting matrices > > Dear Elisa, > Try this: > el<- matrix(1:100,ncol=20) > áset.seed(25) > áel1<- matrix(sample(1:100,20,replace=TRUE),ncol=1) > > In the example you showed, there were no column names.á > > álist(el[,sort(el1)[1:3]],sort(el1,index.return=TRUE)$ix[1:3]) > #[[1]] > á# áá [,1] [,2] [,3] > #[1,]áá 31áá 61áá 71 > #[2,]áá 32áá 62áá 72 > #[3,]áá 33áá 63áá 73 > #[4,]áá 34áá 64áá 74 > #[5,]áá 35áá 65áá 75 > # > #[[2]] > #[1] 9 5 3 > A.K. > > > > > > ________________________________ > From: eliza botto <eliza_botto@hotmail.com> > To: "smartpink111@yahoo.com" <smartpink111@yahoo.com> > Sent: Thursday, April 25, 2013 9:54 AM > Subject: connecting matrices > > > > > Dear Arun, > > [text file contains the exact format] > Although the last codes were absolutely correct and worked the way i want them to. I have an additional cover-up question.á > Suppose i have a matrix "el"....... here i show you only some part of that matrix so that codes can work faster. > > >el > á á á[,595586] [,595587] [,595588] [,595589] [,595590] [,595591] [,595592] [,595593] [,595594] [,595595] [,595596] [,595597] [,595598] [,595599] [,595600] [,595601] > [1,] á á á á55 á á á á55 á á á á55 á á á á55 á á á á55 á á á á55 á á á á55 á á á á55 á á á á55 á á á á55 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 > [2,] á á á á59 á á á á59 á á á á59 á á á á59 á á á á59 á á á á59 á á á á60 á á á á60 á á á á60 á á á á61 á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 > [3,] á á á á60 á á á á60 á á á á60 á á á á61 á á á á61 á á á á62 á á á á61 á á á á61 á á á á62 á á á á62 á á á á58 á á á á58 á á á á58 á á á á58 á á á á58 á á á á59 > [4,] á á á á61 á á á á62 á á á á63 á á á á62 á á á á63 á á á á63 á á á á62 á á á á63 á á á á63 á á á á63 á á á á59 á á á á60 á á á á61 á á á á62 á á á á63 á á á á60 > á á á[,595602] [,595603] [,595604] [,595605] [,595606] [,595607] [,595608] [,595609] [,595610] [,595611] [,595612] [,595613] [,595614] [,595615] [,595616] [,595617] > [1,] á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 á á á á56 > [2,] á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 á á á á57 á á á á58 á á á á58 á á á á58 á á á á58 á á á á58 á á á á58 á á á á58 > [3,] á á á á59 á á á á59 á á á á59 á á á á60 á á á á60 á á á á60 á á á á61 á á á á61 á á á á62 á á á á59 á á á á59 á á á á59 á á á á59 á á á á60 á á á á60 á á á á60 > [4,] á á á á61 á á á á62 á á á á63 á á á á61 á á á á62 á á á á63 á á á á62 á á á á63 á á á á63 á á á á60 á á á á61 á á á á62 á á á á63 á á á á61 á á á á62 á á á á63 > > > In connection to this matrix, there is another matrix which contains coordination values for each of the column of matrix "el" > > >el1 > > [595586,] á 5.67 áá > [595587,] á 55.90 áá > [595588,] á 515 áá > [595589,] á 755 áá > [595590,] á 955 áá > [595591,] á 5.95 áá > [595592,] á 575 áá > [595593,] á 505 áá > [595594,] á 505 áá > [595595,] á 515 áá > [595596,] á 5612 áá > [595597,] á 506 áá > [595598,] á 576 áá > [595599,] á 5126 áá > [595600,] á 5216 áá > [595601,] á 5666 áá > [595602,] á 526 áá > [595603,] á 5.6 áá > [595604,] á 156 áá > [595605,] á 4556 áá > [595606,] á 5556 áá > [595607,] á 1256 áá > [595608,] á 1256 áá > [595609,] á 8756 áá > [595610,] á 5906 áá > [595611,] á 789 áá > [595612,] á 5006 áá > [595613,] á 1256 áá > [595614,] á 3356 áá > [595615,] á 7756 áá > [595616,] á 4456 áá > [595617,] á 3356 áá > > What i want in the end is a list of two elemens containing the 10 column of "el" which have the lowest values in matrix "el1". > > More precisely > [[1]] > [,595603][,595586][595591,] > 565555 > 575959 > 596062 > 626163 > > [[2]] > 5.65.675.95 > > is it possible to carry out such operation?? > > thanks for your help > > Elisaá á á[[alternative HTML version deleted]]