问题
My directory structure is as follows:
c:/Users/bob/MyPackageName
c:/Users/bob/MyPackageName/R
c:/Users/bob/MyPackageName/tests
c:/Users/bob/MyPackageName/tests/testthat
My development session normally consists of starting an R session in the package root (c:/Users/bob/MyPackageName
), and running
devtools::load_all()
devtools::test()
followed by alternating the addition of little bits in MyPackageName/tests/testthat/mytest.R
and in MyPackageName/R/mycode.R
.
When starting a session returns
Loading MyPackageName
Error: object 'compute' not found whilst loading namespace 'MyPackageName'
I try:
- Calling an explicit
devtools::load_all("c:/Users/bob/MyPackageName")
- Searching for an errant instance of
compute
(package required, function name, anything..). But all is good. - Clearing some caches,
rm(list=ls())
. - Calling a localized
devtools::load_all()
from a session inc:/Users/bob/MyPackageName/tests/testthat
and another inc:/Users/bob/MyPackageName/tests/testthat
. - Regenerating the documentation through
devtools::document()
, lest some corruption in those has gone awry. - Delete
MyPackageName/.RData
andMyPackageName/.Rhistory
.
But nothing. I still get Error: object 'compute' not found whilst loading namespace 'MyPackageName'
What else can I try? For example, what is the pre-Devtools method of "loading all"? What is "object 'compute'"?
When I start an R session outside of the package directory, all is well. Hence my R setup is fine; this question is in the context of writing an R package.
回答1:
This may be a work-around. Perhaps you can give it a try.
I have encountered similar error Error: object 'compute' not found whilst ...
when I rebuilt a package (R version 3.5.0, roxygen2 version 3.5.0).
I wound up with manually removing the first row S3method(compute,...)
in NAMESPACE
to get the package rebuilt.
来源:https://stackoverflow.com/questions/49859149/r-packages-error-object-compute-not-found-whilst-loading-namespace