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

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Wed Aug 14 07:44:09 CEST 2019


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

> Compiling the C++ model

(this takes a while) and then

> Start sampling

immediately after which it issues the error message:

> Error in cpp_object_initializer(.self, .refClassDef, ...) : 
>   could not find function "cpp_object_initializer"

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.

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-package-devel mailing list