Worked great, thanks! On Sep 11, 2010, at 8:26 PM, <bill.venab...@csiro.au> <bill.venab...@csiro.au> wrote:
> Is this the kind of thing you are talking about? > > ### 8< cut here 8< ### > A <- rep(NA, 100) > B <- sort(runif(25)) > C <- sort(sample(1:100, 25)) > > A[C] <- B > B > C > A > ### 8< cut here 8< ### > > > (The sorting is not necessary. It's only there to make checking what > happened easier.) > > > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Gregory Ryslik > Sent: Sunday, 12 September 2010 8:54 AM > To: r-help@r-project.org > Subject: [R] mapping array > > Hi, > > Suppose I have array A with 100 elements all filled in with "N/A". Array > B has 25 elements with actual values. Lastly, I have array C that > provides a map of where to put the elements from array A into array B. > Thus C would say put element 1 from B into element 3 from array A. > > I realize I can do this with a for loop. However, because I'm doing a > random forest with this, I'd like to avoid a for loop because it would > take significantly more time. > > Thanks, > Greg > > ______________________________________________ > 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.