0

I got an error as the title shows

Error: object 'Cdqrls' not found 

I use devtools for building R packages, and one function in my current package, I used

.Call(Cdqrls, x[, id1, drop=FALSE] * w, w * z, epsilon) 

and also includes a lm.c file in the src folder, which includes:

... SEXP Cdqrls(SEXP x, SEXP y, SEXP tol) { SEXP ans, ansnames; SEXP qr, coefficients, residuals, effects, pivot, qraux; int n, ny = 0, p, rank, nprotect = 4, pivoted = 0; double rtol = asReal(tol), *work; ... 

directly copied from R source files. When I used load_all() in devtools, it compiles shared objects in src/ (I checked that works well) with new files: lm.o and MyPkgName.so. However, from the wiki of devtools, I found that

load_all ignores the package NAMESPACE 

If working properly, I think by running some functions, I am able to update the NAMESPACE file to contain useDynLib(MyPkgName, Cdqrls). Is that correct? I think in that way the error may disappear... Any suggestions are greatly appreciated!

Update

According to @mnel and this post, it seems that using @useDynLib should work. However, the function I used .Call() is NOT documented, and there are several functions that used .Call so I personally do not wanna document them as they're not used for end-users. Thus, where shall I put @useDynLib?

5
  • Are you using roxygen to create your package? if so stackoverflow.com/questions/8407615/… Commented Apr 9, 2013 at 0:41
  • @mnel: thanks! I am using roxygen2. I read the post you mentioned, and it seems that @ useDynLib is the one to use. Please see the updated post above ;-) Commented Apr 9, 2013 at 1:08
  • @mnel: BTW, shall I use @ useDynLib Cdqrls? Thanks! Commented Apr 9, 2013 at 1:19
  • More likely @useDynLib yourpackagename, or @useDynLib stats if you want to use Cdqrls from the stats package.... Commented Apr 9, 2013 at 1:45
  • @mnel: thanks! I used @ useDynLib pkgname Cdqrls and it works now ;-) Commented Apr 9, 2013 at 2:42

1 Answer 1

1

The answer is to use @useDynLib PkgName Routine1 Routine2 using roxygen2, so that once running document() function in devtools the NAMESPACE file will contain useDynLib(PkgName,Routine1,Routine2), which will work perfectly.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.