We have seen the use of the STL transform functions in the posts
STL transform and
Transforming a matrix.
We use the same logic in conjuction with a logical (ie boolean)
vector in order subset an initial vector.
We can illustrate this on a simple example or two:
[1] 2 4
[1] 3 4 5
Casual benchmarking (not shown) shows this to be comparable to and
even slightly faster than basic indexing in R itself.