I have an R package that I've been building in RStudio, let's called it my_pkg
. When I run devtools::load_all(".")
within RStudio (specifically using the Ctrl + Shift + L
shortcut), I get the following message:
Loading my_pkg Warning messages: 1: character(0) 2: character(0) 3: character(0) 4: character(0) 5: character(0)
All of the functions in the package work fine. My NAMESPACE
and DESCRIPTION
files are complete with no syntax errors. When I run ?my_pkg
, however, the help file does not match the specifications provided in the DESCRIPTION
file. When I remove the Imports
from DESCRIPTION
, there is no more character(0)
warning message. Of course, I need those imports. When I change Imports
to Suggests
, there is character(0)
warning message.
Here is the description file content, with some stuff changed to protect IP.
Package: scoutdroid Title: This is where the title is. Version: 0.1 Authors@R: "Ben Hanowell <[email protected]> [aut, cre]" Description: This is where the description is. Depends: R (>= 3.1.0) Imports: dplyr, lubridate, mboost, randomForestSRC, RODBC, stringr License: file LICENSE LazyData: true
And here is NAMESPACE
.
# Generated by roxygen2 (4.0.1): do not edit by hand import(RODBC) import(dplyr) import(lubridate) import(mboost) import(parallel) import(randomForestSRC) import(stringr)
When I use the RStudio Build & Reload button in the Build tab, I get the following warnings:
** preparing package for lazy loading
Warning: replacing previous import by 'lubridate::intersect' when loading 'scoutdroid' Warning: replacing previous import by 'lubridate::setdiff' when loading 'scoutdroid' Warning: replacing previous import by 'lubridate::union' when loading 'scoutdroid'
edit Added some more details to help folks understand what might be going on.
edit 2 I also added the DESCRIPTION
file, although I don't provide the full package, which is proprietary.
edit 3 Added NAMESPACE
.
edit 4 Added warnings that occur when using RStudio Build & Reload button in the Build tab.
After some dialoge in the comments, we figured out that the empty warnings that load_all
is giving you are actually initiated when loading the package because of function name conflicts.
The issue is that you are importing a function from a package, then overwriting that function. When that happens R throws warnings as you saw when you clicked "Build & Reload" in RStudio:
Warning: replacing previous import by 'lubridate::intersect' when loading 'scoutdroid' Warning: replacing previous import by 'lubridate::setdiff' when loading 'scoutdroid' Warning: replacing previous import by 'lubridate::union' when loading 'scoutdroid'
It looks like load_all
may be attempting to muffle those warnings (just a guess) which is why you see character(0)
instead of the actual warnings. (These particular warnings are difficult to silence.)
It is generally not a good idea to import an entire package's namespace. You should instead import only the symbols you need. See this post of mine for more.
The solution is to use importFrom
instead of import
in your NAMESPACE file.
It can also be due to a broken link in the roxygen2
documentation. For example when you link to a function external to your package with the wrong name, say \link[stringi]{STRI_C}
instead of \link[stringi]{stri_c}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With