<div dir="ltr">Thanks! Working offline would be great!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 28, 2023 at 11:34 AM Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hi Matthew,<br>
<br>
Thanks for circling back!<br>
<br>
On 28 March 2023 at 11:23, Matthew Supernaw - NOAA Federal wrote:<br>
| Hi Dirk,<br>
| Thanks for your attention on this. I was able to find a solution that works for<br>
| us.<br>
| Matthew<br>
| <br>
| <a href="https://github.com/NOAA-FIMS/ModularTMBExample/blob/map/src/" rel="noreferrer" target="_blank">https://github.com/NOAA-FIMS/ModularTMBExample/blob/map/src/</a><br>
| tmb_objective_function.cpp#L133<br>
<br>
Ok -- if you want we can maybe offline work on smoothing that over. You have<br>
Rcpp already at your disposal there, you should not need the darn PROTECT and<br>
UNPROTECT that makes my eyes burn.<br>
<br>
Total aside:  I needed a finger exercise for turning factor to character and<br>
vice verse and just did this (for now (?) in RcppExamples):<br>
<br>
<a href="https://github.com/eddelbuettel/rcppexamples/blob/master/src/makeFactor.cpp" rel="noreferrer" target="_blank">https://github.com/eddelbuettel/rcppexamples/blob/master/src/makeFactor.cpp</a><br>
<br>
and looks like I forgot to rename the file which I may do to FactorExample.cpp<br>
<br>
Dirk<br>
<br>
| On Fri, Mar 24, 2023 at 4:36 PM Jeff Newmiller <<a href="mailto:jdnewmil@dcn.davis.ca.us" target="_blank">jdnewmil@dcn.davis.ca.us</a>><br>
| wrote:<br>
| <br>
|     Well, feel free to ignore my post, but the gist was that anything you have<br>
|     access to in R can be passed by your R API code to your Rcpp code. Also,<br>
|     due to R's GC you should usually avoid caching references between calls to<br>
|     your Rcpp code anyway.<br>
| <br>
|     On March 24, 2023 12:40:43 PM PDT, Matthew Supernaw - NOAA Federal <<br>
|     <a href="mailto:matthew.supernaw@noaa.gov" target="_blank">matthew.supernaw@noaa.gov</a>> wrote:<br>
|     >Hi Jeff,<br>
|     >I'm not sure I understand your comment. The code is part of a package.<br>
|     >We're just trying to sync the declared object name in the R environment to<br>
|     >the object in the Rcpp module programmatically from c++ for internal use.<br>
|     I<br>
|     >just wondered if there was a way to access the wrapped object in the<br>
|     >Rcpp:::PreserveStorage class and Dirk answered that question.<br>
|     >Thanks.<br>
|     >Matthew<br>
|     ><br>
|     ><br>
|     >On Fri, Mar 24, 2023 at 2:34 PM Jeff Newmiller <<a href="mailto:jdnewmil@dcn.davis.ca.us" target="_blank">jdnewmil@dcn.davis.ca.us</a>><br>
|     >wrote:<br>
|     ><br>
|     >> Matthew... the normal context for sharing Rcpp code is within a package.<br>
|     >> It is a no-brainer to have an R API called by the user that calls<br>
|     whatever<br>
|     >> Rcpp code it needs to, which is why your objection seems inappropriate<br>
|     to<br>
|     >> me.<br>
|     >><br>
|     >> On March 24, 2023 10:43:34 AM PDT, Dirk Eddelbuettel <<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>><br>
|     >> wrote:<br>
|     >> ><br>
|     >> >On 24 March 2023 at 13:08, Matthew Supernaw - NOAA Federal wrote:<br>
|     >> >| I'm sure it's possible to do from the R side, however, the<br>
|     requirement<br>
|     >> is to<br>
|     >> >| hide this from the end user and set the reference objects name to the<br>
|     >> declared<br>
|     >> >| name from the R environment. If I view the environment in RStudio,<br>
|     >> there is<br>
|     >> >| much more information available. ls() only returns a list of objects<br>
|     by<br>
|     >> their<br>
|     >> >| declared name. I'm wondering how to get more details about elements<br>
|     in<br>
|     >> the<br>
|     >> >| environment.<br>
|     >> ><br>
|     >> >Thanks for additional color.  That may be a very interesting and<br>
|     valuable<br>
|     >> >question _for the C API of R_ and youe guess of "maybe Rcpp has a<br>
|     helper"<br>
|     >> is<br>
|     >> >a good one.  Sadly, I fear we may not have anything for you.<br>
|     >> ><br>
|     >> >Dirk<br>
|     >> ><br>
|     >> >--<br>
|     >> ><a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
|     >> >_______________________________________________<br>
|     >> >Rcpp-devel mailing list<br>
|     >> ><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">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" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
|     >> --<br>
|     >> Sent from my phone. Please excuse my brevity.<br>
|     >><br>
|     ><br>
|     ><br>
| <br>
|     --<br>
|     Sent from my phone. Please excuse my brevity.<br>
| <br>
| <br>
| <br>
| --<br>
| Matthew Supernaw<br>
| Scientific Software Developer<br>
| National Oceanic and Atmospheric Administration<br>
| Office Of Science and Technology<br>
| NOAA Fisheries | U.S. Department of Commerce<br>
| Phone 248 - 396 - 7797<br>
| <br>
| <br>
<br>
-- <br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Matthew Supernaw<br><i><font color="#666666">Scientific Software Developer</font></i></div><div><span style="line-height:16px;font-family:arial,sans-serif"><em><font color="#666666">National Oceanic and Atmospheric Administration</font></em></span></div><div><i><font face="arial, sans-serif" color="#666666">Office Of Science and Technology</font></i></div><div><font color="#666666"><i><font face="arial, sans-serif">NOAA Fisheries | </font></i><span style="font-family:Arial;font-size:13.3333px;white-space:pre-wrap">U.S. Department of Commerce</span></font></div><div><font color="#666666">Phone 248 - 396 - 7797</font><br><br></div><br></div></div>