operation_sum | R Documentation |
operations can be added together to form stacks of operations, which when multiplied by (applied to) layer-like objects, those layer-like objects are distributed over the operations (i.e. copied).
## S4 method for signature 'operation'
sum(x, ..., na.rm = FALSE)
## S4 method for signature 'operation,operation'
e1 + e2
## S4 method for signature 'operation,numeric'
e1 + e2
## S4 method for signature 'numeric,operation'
e1 + e2
## S4 method for signature 'operation_sum'
format(x, ...)
x, ... |
operations |
na.rm |
ignored |
e1 |
an operation or |
e2 |
an operation or |
Addition of ggblend operations depends on the types of objects being summed:
If you add an operation to an operation, they are merged into a single operation that copies input layer-like objects, one for each operation.
If you add an operation to a numeric()
n, it is equivalent to
adding *
nop()
s to that operation.
An operation.
library(ggplot2)
# adding operations together creates a sum of operations
adjust(color = "red") + adjust(linewidth = 2)
# addition and multiplication obey the distributive law
op = (adjust(aes(y = 11 -x), color = "skyblue") + 1) * (adjust(color = "white", linewidth = 4) + 1)
op
# multiplication by a geom returns a modified version of that geom,
# distributed over the sum of the operations
data.frame(x = 1:10) |>
ggplot(aes(x = x, y = x)) +
geom_line(linewidth = 2) * op
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.