Closed
Description
To me it feels counter intuitive that NULL
is a no-op while list()
results in a modified object. Of course the rendered plots do not differ. In the current definition of function add_ggplot()
the test for returning p
unchanged uses is.null(object)
, one could use length(object) == 0
instead, but maybe it is just me that is surprised, and there is a good reason behind treating NULL
and list()
differently.
library(ggplot2)
myplot <- ggplot(data = mtcars,
aes(x=disp, y=mpg)) +
geom_point()
identical(myplot, myplot + NULL)
#> [1] TRUE
identical(myplot, myplot + list())
#> [1] FALSE
Metadata
Metadata
Assignees
Labels
No labels