Hi all,
I am maintainer of an R package on CRAN which depends on ggplot2
and includes a ggplot2
theme. The in the new version of ggplot2 coming later this months there is a breaking change in the argument size
will be replaced by linewidth
(blog post here) in my case the change affects element_line()
in the theme.
I need to maintain compatibility with the recent ggplot2
version so I have successfully handled this breaking change with utils::packageVersion
as shown the code below. However when building my package or running a CRAN check with ggplot2
<= 3.3.6. I get the following NOTE:
checking R code for possible problems ... NOTE
Note: possible error in 'element_line(linewidth = 0.25)", ': unused argument (linewidth = 0.25) at themes_gg.R:33
Because of this all my continuous integration workflows fail.
So my question is: is there a way to prevent from R code that is not supposed to be run under the current version? Or is there a better approach than the one I have used to handle this?
R code example from handling code across multiple dependency versions:
if (utils::packageVersion("ggplot2") > "3.3.6") {
panel_line <- element_line(linewidth = 0.25)
} else {
panel_line <- element_line(size = 0.25)
}
theme(panel.grid.major = panel_line)