I am building a package that extends the functionality of another package, crmPack. crmPack uses S4 classes. I'm using roxygen to document my new package. I'm getting an error when running devtools::check() on my new package:
> checking examples ... ERROR
Running examples in ‘crmreporter-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: summariseIncrementsRule
> ### Title: Create a Tibble Describing an Increments Rule
> ### Aliases: summariseIncrementsRule
>
> ### ** Examples
>
> if (requireNamespace("crmPack")) {
+ inc <- IncrementsRelative(intervals=c(0, 20), increments=c(1, 0.33))
+ summariseIncrementsRule("inc")
+ }
Error in IncrementsRelative(intervals = c(0, 20), increments = c(1, 0.33)) :
could not find function "IncrementsRelative"
Execution halted
Here's the relevant section of the roxygen comments and the definition of the generic in question:
#' @examples
#' if (requireNamespace("crmPack")) {
#' inc <- IncrementsRelative(intervals=c(0, 20), increments=c(1, 0.33))
#' summariseIncrementsRule(inc)
#' }
#' @import crmPack
#' @importFrom methods .valueClassTest
#' @export
setGeneric("summariseIncrementsRule", valueClass = "tbl", function(object) {
standardGeneric("summariseIncrementsRule")
})
I have also tried
#' @importFrom crmPack IncrementsRelative
in the roxygen comments for the generic, with the same result.
crmPack appears in the Imports: section of my DESCRIPTION file and my NAMSEPACE file includes import(crmPack).
How should I document my generic so that its example runs correctly? [Which it does when run from the console.]
Following on from @Waldi's question, I tried:
And this ran without error. I was also able to remove
#' @import crmPackfrom theroxygencomments, but removing#' @importFrom methods .valueClassTestcauseddevtools::check()to issue a warning.