Re: [R] filling values in a vector using smaller vector

2008-12-24 Thread Wacek Kusnierczyk
Milton Huang wrote: > Thank you both for such beautiful solutions. Just what I was looking for! I > love the Internet, R, and the R-list! There is so much opportunity to learn. > > In fact, looking at the replace function, I see the two solutions are the > same: > > >> replace >> >

Re: [R] filling values in a vector using smaller vector

2008-12-24 Thread Milton Huang
Thank you both for such beautiful solutions. Just what I was looking for! I love the Internet, R, and the R-list! There is so much opportunity to learn. In fact, looking at the replace function, I see the two solutions are the same: > replace function (x, list, values) { x[list] <- valu

Re: [R] filling values in a vector using smaller vector

2008-12-24 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > Milton Huang wrote: >> >> >>> Dear list members: >>> >>> I am looking for an elegant (or efficient) way to accomplish the following: >>> >>> take a large boolean vector and fill the TRUE values with the values from a >>> smaller boolean vector that has a length t

Re: [R] filling values in a vector using smaller vector

2008-12-24 Thread Patrick Burns
I believe the following does what is wanted: desired <- large desired[large] <- small Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Milton Huang wrote: Dear list members: I am looking for an elegan

Re: [R] filling values in a vector using smaller vector

2008-12-24 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > Milton Huang wrote: > >> Dear list members: >> >> I am looking for an elegant (or efficient) way to accomplish the following: >> >> take a large boolean vector and fill the TRUE values with the values from a >> smaller boolean vector that has a length that is the numb

Re: [R] filling values in a vector using smaller vector

2008-12-24 Thread Wacek Kusnierczyk
Milton Huang wrote: > Dear list members: > > I am looking for an elegant (or efficient) way to accomplish the following: > > take a large boolean vector and fill the TRUE values with the values from a > smaller boolean vector that has a length that is the number of TRUE values of > the large vect

[R] filling values in a vector using smaller vector

2008-12-24 Thread Milton Huang
Dear list members: I am looking for an elegant (or efficient) way to accomplish the following: take a large boolean vector and fill the TRUE values with the values from a smaller boolean vector that has a length that is the number of TRUE values of the large vector. Example: large<- c(FALSE,