Exported function not exported correctly
Asked Answered
P

1

10

I am developing an R package (let's call it pkg), and I have defined a few generics. The NAMESPACE file contains both

S3method(foo, bar)
export(foo)

However, upon calling pkg::foo.bar, I get the dreaded

Error: 'foo.bar' is not an exported object from 'namespace:pkg'

I am using roxygen2, if that changes anything.

Note: If I explicitly add export(foo.bar), then everything works.

Pacheco answered 6/4, 2016 at 5:19 Comment(4)
if you use devtools, @export for all generic/methods? it always worked fine for me (more doc here. Is foo a method you created or do you extend one ?Jumble
Yes, all generics are exported.foo is a method that I created, and is being called from another package I am writing (e.g. secondPkg imports pkg and is trying to call pkg::foo.bar).Pacheco
I had same problem...many expletives later I discovered that NAMESPACE (and thus exports) is only updated when you run devtools::document() - not devtools::build() or devtools::install()Torrent
@virgesmith: This solved my problem too. Please consider writing an answer.Kempis
O
4

NAMESPACE (and thus exports) is only updated when you run devtools::document() - not devtools::build() or devtools::install().

Ossetia answered 7/6, 2023 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.