"could not find function" when running examples in package check

Viewed 781

When running R CMD check I am getting

> checking examples ... ERROR
...
...
  > lfqplotter$pca()
  Error in inner_join(wide$annotation, xx) : 
    could not find function "inner_join"
  Calls: <Anonymous> -> <Anonymous>
  Execution halted

A similar question was asked before. "Could not find function" in Roxygen examples during CMD check

But in my case it is a function from an imported package (dplyr), which I did list under Imports in the DESCRIPTION file.

Imports:
dplyr

I know that I could specify and @importFrom clause with roxygen2. However because the package contains dozens of functions with examples, and many use dplyr::inner_join and other dplyr functions, I would prefer not have to fill the comments with hundreds of @importFrom dplyr inner_join select etc etc, or be adding @import dplyr everywhere. Alternatively, I could, but I do not want to prefix every dplyr function call with dplyr::. Is there any other option to get examples working and imported package functions visible?

Answer

Based on the Answer by @Roland and @Waldi I added an R file AAA_importFrom.R to the project with a block of:

#' @importFrom tidyr ...
#' @importFrom dplyr ...
...
#'
NULL

and removed all the @importFrom clauses from the function documentations.

1 Answers

You should also have :

importFrom(dplyr,inner_join)

in NAMESPACE

you can get Roxygen to create this in NAMESPACE by having :

#' @ImportFrom dplyr inner_join
NULL

in one of your package's R scripts

Related