Skip to content

[R-pkg-devel] Imported function cannot be found.

5 messages · Dirk Eddelbuettel, Rolf Turner

#
I am build a package in which there is a function which calls upon the 
function brm() from the brms package.

In my DESCRIPTION file I have the line
In my NAMESPACE file I have the line
Yet when I call the function from my package which calls brm() I get the 
error message:
Clearly I am doing something wrong.  Can someone please point me in the 
direction of correctness?

Note that there is indeed a function cpp_object_initializer() in the 
Rcpp package.

If more detail is required in order for guidance to be provided I am of 
course more than happy to supply such detail.

cheers,

Rolf Turner
#
On 18 January 2019 at 11:59, Rolf Turner wrote:
| 
| I am build a package in which there is a function which calls upon the 
| function brm() from the brms package.
| 
| In my DESCRIPTION file I have the line
| 
| > Imports: lme4, brms, glmmTMB, MASS, lattice, Rcpp, rmutil
| 
| In my NAMESPACE file I have the line
| 
| > importFrom("Rcpp","cpp_object_initializer")
| 
| Yet when I call the function from my package which calls brm() I get the 
| error message:
| 
| > Error in cpp_object_initializer(.self, .refClassDef, ...) : 
| >   could not find function "cpp_object_initializer"
| 
| Clearly I am doing something wrong.  Can someone please point me in the 
| direction of correctness?
| 
| Note that there is indeed a function cpp_object_initializer() in the 
| Rcpp package.
| 
| If more detail is required in order for guidance to be provided I am of 
| course more than happy to supply such detail.

Which of these packages uses Rcpp Modules?  Yours?  brms::brm()

It may be more prudent replace

   importFrom("Rcpp","cpp_object_initializer")

with

   import(Rcpp)

which tickles a different initialization for Rcpp. I just checked two Rcpp
Modules using packages of mine, and they use that latter approach.

Hth, Dirk
#
Thanks Dirk.  Your suggestion worked perfectly.  (See inline below.)
On 1/18/19 2:50 PM, Dirk Eddelbuettel wrote:
Definitely brms:brm()!!!  Using Rcpp is far beyond my limited capabilities.
Yep.  Tried that, and it works.  It all seems like sorcery to me, but I 
guess if I (or somebody more clever than I, e.g. your very good self) 
can get it to work, then that's all that matters.

Thanks again.

cheers,

Rolf
#
On 18 January 2019 at 15:13, Rolf Turner wrote:
| 
| Thanks Dirk.  Your suggestion worked perfectly.  (See inline below.)

Glad to hear.
| On 1/18/19 2:50 PM, Dirk Eddelbuettel wrote:
| >
| > On 18 January 2019 at 11:59, Rolf Turner wrote:
[...]

| > Which of these packages uses Rcpp Modules?  Yours?  brms::brm()
| 
| Definitely brms:brm()!!!  Using Rcpp is far beyond my limited capabilities.
| 
| > It may be more prudent replace
| > 
| >     importFrom("Rcpp","cpp_object_initializer")
| > 
| > with
| > 
| >     import(Rcpp)
| > 
| > which tickles a different initialization for Rcpp. I just checked two Rcpp
| > Modules using packages of mine, and they use that latter approach.
| 
| Yep.  Tried that, and it works.  It all seems like sorcery to me, but I 
| guess if I (or somebody more clever than I, e.g. your very good self) 
| can get it to work, then that's all that matters.

Something is off the rocker here as you should not have to do anything here
besides importing brms::brm.  That another package uses Rcpp should not force
you to do something so I suspect something else is amiss.  But based on the
information given I can not think of a suggestion. As they say: Oh well ...

Dirk
#
On 1/18/19 4:08 PM, Dirk Eddelbuettel wrote:
<SNIP>
Yeah, I thought it a bit odd when what I tried initially didn't work. 
But as I indicated earlier, all this business about Depend, Suggests, 
Imports etc. and the distinctions between them seems like sorcery to me.
And since what I have now tried, on the basis of your suggestion, *does* 
work, I think that "Oh well ..." is the right answer to the conundrum.

cheers,

Rolf