Skip to content

make list() behave as NULL #2315

Closed
Closed
@aphalo

Description

@aphalo

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions