Reputation: 824
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:
devtools::load_all("c:/Users/bob/MyPackageName")
compute
(package required, function name, anything..). But all is good.rm(list=ls())
.devtools::load_all()
from a session in c:/Users/bob/MyPackageName/tests/testthat
and another in c:/Users/bob/MyPackageName/tests/testthat
.devtools::document()
, lest some corruption in those has gone awry.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.
Upvotes: 1
Views: 1892
Reputation: 304
It's hard to tell without seeing the function names but this could be an issue since ROxygen >3 now uses @export
for both S3 objects and functions. Therefore, if you have a function using dots e.g. compute.something.cool()
and you use ROxygen's #' @export
, it might be inferring that it is a S3 object rather than a function.
This is described in more detail here but in short explicitly name your function with the export call:
#' @export compute.something.cool
This approach will mean you can still use devtools::document()
to keep your NAMESPACE updated without having to manually do it. A note, that Bioconductor do not permit packages to use dot naming conventions, probably for this very reason so it might be worth avoiding this in the future.
Upvotes: 0
Reputation: 31
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.
Upvotes: 3