[R] mapping array
Gregory Ryslik
rsaber at comcast.net
Sun Sep 12 19:58:18 CEST 2010
Worked great, thanks!
On Sep 11, 2010, at 8:26 PM, <Bill.Venables at csiro.au> <Bill.Venables at 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-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Gregory Ryslik
> Sent: Sunday, 12 September 2010 8:54 AM
> To: r-help at 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 at 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.
More information about the R-help
mailing list