'Importing a R base S3 method with custom class from a package to another

I have the following S3 method in package foo:

print.foo <- function(x, ...) # do sth

I would like to import that method in package bar but get the following warning:

object ‘print.foo’ is not exported by 'namespace:foo'

I tried importing the method using a standard @export and @exportS3Method base::print, which produces the following NAMESPACE in foo after running devtools::document():

S3method(base::print,foo)

Then I imported the method in bar using @importFrom foo print.foo.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source