I have the following dependency chain in a package I'm developing:
- My package uses a class (
trajectory
) defined in package A (simmer
). - It also uses an S3 method for that class (
plot.trajectory
), which is defined in package B (simmer.plot
). - I can import package A as a whole, but I cannot import package B as a whole, because it contains replacements for other functions defined in package A (the
get_mon
functions), so I get unwanted warnings about the original functions being replaced.
How do I use/import the S3 method without importing the rest of package B, preferably via roxygen2
?
The roxygen2
documentation suggests the following:
If you want to add a new method to an S3 generic, import it with @importFrom pkg generic.
For my example, this would be @importFrom simmer.plot plot
, but this returns a warning that plot
is not exported by simmer.plot
. The same thing happens if I import the generic first, using @importFrom graphics plot
.
#' @importFrom simmer.plot plot.trajectory
? – duckmayrplot.trajectory
isn't exported bysimmer.plot
, even though I can see that it is on its GitHub repository: github.com/r-simmer/simmer.plot/blob/master/NAMESPACE – Accidental Statistician