<div dir="ltr">Dirk,<div><br></div><div>So either or :</div><div><ul><li>I copy adist_full code source (not really familiar but I ll give it a try)</li><li>Or easier solution , I'll explore levenshteiSim function from <a href="http://cran.r-project.org/web/packages/RecordLinkage/index.html">RecordLinkage </a>package.</li>
</ul><div><br></div></div><div>Thanks.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 30, 2013 at 7:33 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Amine,<br>
<div class="im"><br>
On 30 December 2013 at 19:26, contact AG STUDY wrote:<br>
| I need to call R adist function over a big vector, many times.<br>
| Internally , adist is calling adist_full defined in src/main/agrep.c. So<br>
| wonder If I can call the c function adist_full directly from my c++ code.<br>
<br>
</div>You may need to reimplement the adist_full() function in your own package.<br>
You can start by copying it and then figuring out one-by-one what the<br>
dependencies are, and satisfy those.<br>
<br>
I am not so familiar with the NPL and text regression fields, but similar<br>
functionality may be available somewhere else too.<br>
<div class="im"><br>
| My workaround is to give adist as a Function parameter. here my code:<br>
| #include <Rcpp.h><br>
| using namespace Rcpp;<br>
|<br>
| // [[Rcpp::export]]<br>
| List call_adist(CharacterVector y, Function f,int tol=16) {<br>
|     std::vector<std::vector<int> > out;<br>
|     std::vector<std::string> input = as<std::vector<std::string> >(y);<br>
|     for (std::vector<std::string>::iterator it = input.begin() ; it !=<br>
| input.end(); ++it){<br>
|       //  can I change f call by adist_full(*it,y,costs,false)?<br>
|         std::vector<int> res = as<std::vector<int> >(f(*it,y)); <br>
<br>
</div>This will indeed not be fast as you call out to R each time. You would need<br>
this functionality as C/C++ code.<br>
<br>
Dirk<br>
<div class="im"><br>
<br>
|         out.push_back(res);<br>
|     }<br>
|     return Rcpp::wrap(out);<br>
| }<br>
| Then I call it like :<br>
|<br>
|     call_adist(vv,adist)<br>
|<br>
| But this is less efficient than lapply(vv,adist).<br>
|<br>
| Happy New Year!<br>
|<br>
|<br>
|<br>
|<br>
|<br>
</div>| ----------------------------------------------------------------------<br>
| _______________________________________________<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>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<span class="HOEnZb"><font color="#888888">--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br></div>