<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi All: I wrote below and it works but I have a strong feeling there's a better way to do it. I looked on the net and found some material from back in ~2014 about concatenating</div><div>vectors but I didn't see anything final about it. Thanks for any insights.</div><div><br></div><div>Also, the documentation for Rcpp is beyond incredible (thanks to dirk, romain, kevin and all the other people I'm leaving out )  but is there a general methodology for finding equivalents of R functions. For example, if I want a cumsum function in Rcpp, how do I know whether to use the stl with accumulate or if there's already one built in so</div><div>that I just call cumsum.</div><div><br></div><div>Thanks.</div><div><br></div><div>#=======================================================<br></div><div><br></div><div>#include <Rcpp.h><br>using namespace Rcpp;<br><br>// [[Rcpp::export]]<br>std::vector<double> mybar(const std::vector<double>& x, double firstelem) {<br>  std::vector<double> tmp(x.size() + 1);<br>  tmp[0] = firstelem;<br>  for (int i = 1; i < (x.size()+1); i++)<br>    tmp[i] = x[i-1];<br>  return tmp;<br>}<br><br>/*** R<br><br>testvec = c(1,2,3)<br>testelem <- 7<br>mybar(testvec,testelem)<br> <br>*/<br></div><div><br></div><div>#===============================<br></div><div># OUTPUT FROM RUNNING ABOVE<br></div><div>#=================================<br></div><div>> testvec <-  c(1,2,3)<br>> testelem <- 7<br>> mybar(testvec,testelem)<br>[1] 7 1 2 3<br>> </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div>