I am developing an R package that wraps the rmongodb
package and creates a developer-friendly interface for working with MongoDB. The package uses proto
internally.
I'd like to export a single factory method via a proto object (an environment) called MongoDB
, whose definition is:
MongoDB <- proto(
new = function(., ...) {
# Good stuff in here...
}
)
During development with RStudio & devtools
and during local testing this does not seem to be a problem. However, I am experiencing several problems:
devtools::check()
insists on putting an import(MongoDB)
in my NAMESPACE file which makes R CMD check
fail with "Namespace dependency not required: 'MongoDB'".
When I remove this import directive, R CMD check
fails with "object 'MongoDB' not found" while running my testthat
tests, even if I manually add export(MongoDB)
. However, devtools::test()
works fine in RStudio.
What is the recommended way of exporting proto
objects, which are environments, from R packages?
Update:
Per Gabor's suggestion below, I've made sure that MongoDB.Rd
declares MongoDB
as data (the link has the source). I still get a failure in MongoDB
not being visible in the tests (which use testthat
). My DESCRIPTION
file is here and NAMESPACE
is here.
Try this:
export("MongoDB")
in your NAMESPACE
file to make the MongoDB
proto object publicly available.LazyData: yes
in your DESCRIPTION
file so that it automatically loads when accessed..Rd
file documenting it as a dataset.It should then pass R CMD check
.
This directive :
import(MongoDB)
means that you import the MongoDB
namespace into your package. Probably not what you want if i understand correctly.
I think you want to export the MongoDB
object, then
export(MongoDB)
should work fine.
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