p <- ggplot(mpg, aes(displ, hwy, size = hwy)) +
geom_point()
p + scale_size(
name = waiver(),
breaks = waiver(),
labels = waiver(),
limits = NULL,
range = c(1, 10),
trans = "identity",
guide = "legend"
)
In the above code what does 'waiver()' means and what it function?
You can look up the documentation for waiver by typing ?waiver
into the R console. The scale_size
documentation also describes its purpose in your use case.
In sum, waiver()
specifies that a function should use a default value as a particular argument.
So, in your example, if name = waiver()
, the name of the scale is taken from the first mapping used for that aesthetic. Likewise if breaks = waiver()
or labels = waiver()
, default breaks and labels are used by the function.