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.
Importsin the DESCRIPTION file (study Writing R Extensions). You must additional import specific (or all) functions in your NAMESPACE file. An alternative option would be to list the package underDependsin your DESCRIPTION file. But that's not recommended practice (in particular fordplyrwhich is not shy with masking base functions). - Roland@importor@importFromdirectives in roxygen2. Unfortunately, you say you are unhappy with these. So, you don't want roxygen2 to manage your NAMESPACE file but you also don't want to manage it manually. I'm not sure what kind of advice you are looking for if you already exclude all sensible options. - Roland