0

My NAMESPACE file is:

# Generated by roxygen2 (4.0.1): do not edit by hand
export(ARorderG)
export(VOBoegmc)
export(conddiffG)
................
export(sablon)

Upon trying to check the package via:

devtools::check("C:/Users/erdogan/Documents/Revolution/causfinder")

I received lots of errors like that:

conddiffG: *no visible global function definition for* 'b.star'. 

What I have already tried till now: I added the following importfrom to NAMESPACE file manually:

importFrom(np, b.star)

I did these for all the "...no visible global function definition for..." errors. Then once more I triggered:

devtools::check("C:/Users/erdogan/Documents/Revolution/causfinder")

Unfortunately, all the importFrom statements were automatically deleted from NAMESPACE file. I read that this is due to re-creation of NAMESPACE file from roxygen2.

I needed importFrom statements for successful check of package to send CRAN, but roxygen2 auto-deletes these importFrom statements and left only export statements.

How to prevent deletion of importFrom statements via using roxygen2?

Any help is greatly appreciated in advance.

Erdogan CEVHER
  • 1,788
  • 1
  • 21
  • 40
  • What is `b.star`? Those errors generally mean you're trying to use an undeclared function somewhere in your package code. You want to remove those situations or handle imports/depends correctly in DESCRIPTION (or, I guess, in your Roxygen markup) rather than try to get around them in a hackish way. – Thomas Aug 01 '14 at 12:28
  • @Thomas, b.star is a function that automatically finds optimal lengths in bootstrapping in tsboot. That's to say, b.star is a function in np. When my importFrom's are auto-deleted from NAMESPACE, I faced with "undeclared function somewhere in my package code" as you said. My DESCRIPTION file includes Imports: np(>= 0.50-1), and my un-auto-deleted NAMESPACE file includes importFrom(np,b.star). i.e. I am over-killing the prob. of facing an error, but do not understand why it remains. The Imports: np(>= 0.50-1) in DESC is not auto-deleted, and still undeclared func. error. Very interesting! – Erdogan CEVHER Aug 01 '14 at 12:36
  • Are you putting the relevant `@importFrom np b.star` in your roxygen markup? Because then the importFrom line in `NAMESPACE` should be written automatically? – Thomas Aug 01 '14 at 12:46
  • Thomas, I am not putting relevant @importFrom np b.star in my roxygen markup. I do not know to which file I must put it. What is the most proper place to put that mark up? In R working directory, package's R folder's help.R file? – Erdogan CEVHER Aug 01 '14 at 13:04
  • It's part of your .R file where you write your roxygen markup (like where `@export` line is in [the roxygen2 README example](http://cran.r-project.org/web/packages/roxygen2/README.html)). Perhaps you need to review the basics of roxygen before you try to solve this specific issue. – Thomas Aug 01 '14 at 13:07
  • Hımmm, I understand, you mean put "@importFrom np b.star" to the function of the package that used b.star. I will report you the result after I make all the relevant changes in R. files of the functions of the package. Thanks a lot. – Erdogan CEVHER Aug 01 '14 at 13:13

1 Answers1

4

roxygen2 automatically updates the content of NAMESPACE file. Hence, in order to prevent importFrom statements in NAMESPACE file from auto-deletion, these statements must be brought to the NAMESPACE file from the .R files of the functions of the package; not to be written manually to NAMESPACE file. For the sake of arguement, let the function conddiffG use some function b.star of the package np. Then, in conddiffG.R of R folder of the package, we must write the following just before #' @export line:

#’ @importFrom np b.star

This will create importFrom(np,b.star) in NAMESPACE file automatically during the later processes (roxygenize, build, install, library, devtools::check("C:/Users/erdogan/Documents/Revolution/thePacketContainingconddiffG")...).

Erdogan CEVHER
  • 1,788
  • 1
  • 21
  • 40
  • Depends. Are you using RStudio? If so you can turn it off in "Project Options" – Rich Scriven Aug 02 '14 at 14:37
  • I installed R, RStudio, Revolution R to my PC. But I work with Revolution R and develop my functions and packages in Revolution R. Anyway, I will do what you say about RStudio: turning it off from Project Options. – Erdogan CEVHER Aug 02 '14 at 19:38