R packages: “Error: object 'compute' not found whilst loading namespace ..”

佐手、 提交于 2019-12-11 15:54:17

问题


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:

  1. Calling an explicit devtools::load_all("c:/Users/bob/MyPackageName")
  2. Searching for an errant instance of compute (package required, function name, anything..). But all is good.
  3. Clearing some caches, rm(list=ls()).
  4. Calling a localized devtools::load_all() from a session in c:/Users/bob/MyPackageName/tests/testthat and another in c:/Users/bob/MyPackageName/tests/testthat.
  5. Regenerating the documentation through devtools::document(), lest some corruption in those has gone awry.
  6. Delete MyPackageName/.RData and MyPackageName/.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!