I must have been away from writing R/Rcpp code for too long.
I started off trying to reproduce a calculation that is, literally, a one-liner in Julia. See
http://nbviewer.ipython.org/gist/dmbates/9746197
Now admittedly the calculation of the sums of the n choose k possible subsets of size k from a vector or length n is aided by the fact that there is a combinations iterator in Julia. Nonetheless it is pretty amazing that this can be written as
combsums(v::Vector, k) = [sum(c) for c in combinations(v,k)]
using this iterator and a comprehension.
I tried to write the combinations iterator in C++ but eventually tied myself in knots so I decided to back off and write a function that does the equivalent of the R function sample() and use that to generate a random sample from the distribution of sums.
I have the C++ code working using Rcpp attributes but now I must generate a package. I have to be missing something obvious because my attempt at
http://github.com/dmbates/randomizationTest
produces the dread "function 'dataptr' not provided ..." message when I try to invoke the R function randomsums.
Which of the many vignettes or manuals should I start reading?
(I can't believe I have spent two days going through innumerable contortions to try to achieve the effect of a one-liner.)