Sort of like this? > A<-c(3,5,7,18,43,85,91,98,100,130,230,487) #data values > B<-c(10,5,5,10,8,11,2,7,3,11,10) #random numbers (sample) > > C = A[B] > C [1] 130 43 43 130 98 230 5 91 7 230 130
On Wed, Jul 22, 2009 at 2:08 PM, Erik Iverson<[email protected]> wrote: > A[B] > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of MarcioRibeiro > Sent: Wednesday, July 22, 2009 2:31 PM > To: [email protected] > Subject: [R] Merge vectors > > > Hi listers, > I would like to merge two vectors as follows... > A<-c(3,5,7,18,43,85,91,98,100,130,230,487) #data values > B<-c(10,5,5,10,8,11,2,7,3,11,10) #random numbers (sample) > I would like to set the vector of random numbers according to the order set > of the vector of data values... > The result would be: (130,43,43,130,98,230,5,91,7,230,130) > I could do this with merging, but I would need to set a primary key to merge > the vectors... Is there a way of doing directly... > Thanks in advance, > Marcio > > > -- > View this message in context: > http://www.nabble.com/Merge-vectors-tp24612997p24612997.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [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 > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > [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 > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [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 and provide commented, minimal, self-contained, reproducible code.

