Skip to content

[R-pkg-devel] Error ... could not find function ...

3 messages · Dirk Eddelbuettel, Rolf Turner

#
I am encountering an error that I cannot understand in a package that I 
have built (currently just for personal use; not uploaded to CRAN).

In this package ("ldEst") I have a function ldFit() which calls the 
function brm() from the brms package.  The function brm() makes heavy 
use of the Rcpp package.

When I invoke ldFit() (in the appropriate manner) it duly calls brm() 
and issues messages
(this takes a while) and then
immediately after which it issues the error message:
The function cpp_object_initializer() is to be found in the Rcpp 
package.  I have import("Rcpp") in the NAMESPACE file for "ldEst"
which I thought would make everything from Rcpp available --- but 
apparently not.

If I put a browser() into ldFit(), just before the call to brm(), I
can access cpp_object_initializer() from the browser() prompt.  So why 
cannot brm() access this function?

An irksome aspect to all this is that "*it used to work*".  I haven't 
invoked ldFit() in such a way that brm() gets called upon, for quite 
some time.  But the *last* time (some months ago) that I did so, it 
worked just fine.  Something has changed in the intervening months!

Can anyone suggest how I might solve this conundrum[1] ?  Do I need to
say something other than import("Rcpp") in my NAMESPACE file?  What else
can I try?

Thanks for any insights.

[1] Not to be confused with a birth control device.

cheers,

Rolf Turner

P.S.  I could probably, with a bit of effort, put together a toy package 
that would yield a reprex, if this is deemed necessary.

R. T.
#
On 14 August 2019 at 17:44, Rolf Turner wrote:
| > Error in cpp_object_initializer(.self, .refClassDef, ...) : 
| >   could not find function "cpp_object_initializer"

This can happen when a package using Rcpp Modules is not fully loaded. While
I am not familiar with eiher package here, try `import(brms)` and / or
`importFrom(...)` for a particular routine.

Dirk
#
On 14/08/19 8:30 PM, Dirk Eddelbuettel wrote:
Thanks.  I'll experiment with those ideas.

cheers,

Rolf