[Rcpp-devel] Question on syntactic sugar

Dirk Eddelbuettel edd at debian.org
Thu Jan 5 15:32:41 CET 2012


On 5 January 2012 at 07:41, Gregor Kastner wrote:
| Dear all,
| 
| I have a (small) vector "r" containing values and a (large) vector
| "index" containing indices. Is there an easy way to select the elements of
| "r" that are indexed by "index"?
| 
| I.e., is there a way to reproduce the following R code with Rcpp (without
| using loops)?
| 
| r <- c(1,11,111)
| index <- c(2,2,1)
| r[index]

That was just discussed _yesterday_ on this list.

And no, I don't think it is. Would be nice -- patches welcome.

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list