<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">You need to import something, anything from Rcpp’s namespace. Sent you a pull request. <div><div><br><div><div>Le 25 mars 2014 à 20:17, Douglas Bates <<a href="mailto:bates@stat.wisc.edu">bates@stat.wisc.edu</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I must have been away from writing R/Rcpp code for too long.<div><br></div><div>I started off trying to reproduce a calculation that is, literally, a one-liner in Julia.  See</div><div><br></div><div><a href="http://nbviewer.ipython.org/gist/dmbates/9746197">http://nbviewer.ipython.org/gist/dmbates/9746197</a><br>
</div><div><br></div><div>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</div>
<div><br></div><div>combsums(v::Vector, k) = [sum(c) for c in combinations(v,k)]</div><div><br></div><div>using this iterator and a comprehension.</div><div><br></div><div>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.  </div>
<div><br></div><div>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</div><div><br></div><div><a href="http://github.com/dmbates/randomizationTest">http://github.com/dmbates/randomizationTest</a></div>
<div><br></div><div>produces the dread "function 'dataptr' not provided ..." message when I try to invoke the R function randomsums.</div><div><br></div><div>Which of the many vignettes or manuals should I start reading?</div>
<div><br></div><div>(I can't believe I have spent two days going through innumerable contortions to try to achieve the effect of a one-liner.) </div></div>
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</blockquote></div><br></div></div></body></html>