<div dir="ltr"><div><br></div><div>Here is a MWE of the workflow I was describing for passing a user-d</div><div><br></div><div><a href="https://gist.github.com/kylebmetrum/6b31775702e1b8441a1cff669aeb0f1d" target="_blank">https://gist.github.com/kylebmetrum/6b31775702e1b8441a1cff669aeb0f1d<br></a></div><div><br></div><div>I used sourceCpp() to mimic the code in an R package and used R CMD SHLIB to compile the user function.  It would be great to be able to use sourceCpp() to compile the user function too, but I wasn't sure how to determine the name of the dll (to pass as PACKAGE to getNativeSymbolInfo()).</div><div><br></div><div>Anyway ... maybe there is a simpler way to do it.  But this is basically what I do in mrgsolve.</div><div><br></div><div>Best Regards,</div><div>Kyle</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 14, 2016 at 5:03 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"><span class=""><br>
On 14 April 2016 at 17:28, Martin Lysy wrote:<br>
| I am very grateful for your input/recommendations.  Let me try to wrap my head<br>
| around how to do this with a single package and get your approval on an MWE.<br>
<br>
</span>That's the spirit, and we'll try to help.<br>
<br>
I won't claim that this is _trivial_ but it is _very expressive_ and<br>
powerful.  A worked example is in RcppDE:  user-provided objective function<br>
as C++ code, passed down to the bowels of the optimizer.  The interface takes<br>
a little getting used but I think we have both a Rcpp Gallery piece on it,<br>
and I used it as a running example in a few talks to Google may lead us to<br>
the right slide deck.<br>
<br>
That said, no point in overcomplicating things but ... your initial problem<br>
was a self-inflicted linking issue just because you wanted to avoid a<br>
package.<br>
<br>
Don't.<br>
<br>
Let users work with with sourceCpp() or cppFunction().  What comes out is a<br>
callable R object to just pass into your code.  That's all you need.<br>
<br>
Good luck, Dirk<br>
<br>
PS And whatever you do don't listen to your colleage Markus Hofter who has<br>
really weird coding habits too.  Just kidding.  Tell him I said Hi.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Kyle Baron<div><div>Metrum Research Group</div><div><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice">860-735-7043, Ext. 202<br></span></span></span></span></span></span></span></span></span></span></span></div><div><span style="font-family:Helvetica;font-size:12px"><a href="mailto:kyleb@metrumrg.com" target="_blank">kyleb@metrumrg.com</a></span></div><div><br></div></div></div></div>
</div>