Robin
Robin

Reputation: 31

ImportFrom function in NAMESPACE is removed upon document()

I am receiving an error [could not find function "str_trim"] when I run check() on an R package I am developing. I have since added two things:

1) In DESCRIPTION
Imports: stringr

2) In NAMESPACE
importFrom(stringr,str_trim)

However, when I then run install() and document(), then the line in NAMESPACE is removed. Then, when I again run check(), I receive the original error.

Why is this line being removed? Should I try a different approach, and if so, what kind of approach? Thank you!

Upvotes: 3

Views: 1096

Answers (1)

Martin Mächler
Martin Mächler

Reputation: 4765

It seems you are doing package development "the Hadley way". Hadley wants you to use roxygen (i.e. the roxygen2 package but that should be automatic if you use his 'devtools'). Then, the roxygen "magic" is used to auto-write your NAMESPACE file... and so also destroys things you've put there. You must add @importFrom .... statements to your R/*.R files if you want to use roxygen.

I agree with many things Hadley advocates; the wholesale use of 'roxygen' is not among them however. I want good, carefully maintained help files with \link{}s, \eqn{}, etc etc -> I edit my man/*.Rd files and I manually build NAMESPACE (so it ends up looking well organized, I can also add comments there, and I can even use if(getRVersion() >= "3.2.0") { ...... } in the NAMESPACE file, something that's not easily possible with roxygen.

Upvotes: 10

Related Questions