operation_product {ggblend} | R Documentation |
Layer operation products
Description
operations can be multiplied together to form chains of operations, which when multiplied by (applied to) layer-like objects, return modified layer-like objects.
Usage
## S4 method for signature 'operation,ANY'
e1 * e2
## S4 method for signature 'ANY,operation'
e1 * e2
## S4 method for signature 'adjust,adjust'
e1 * e2
## S4 method for signature 'nop,nop'
e1 * e2
## S4 method for signature 'operation,nop'
e1 * e2
## S4 method for signature 'operation_sum,nop'
e1 * e2
## S4 method for signature 'nop,operation'
e1 * e2
## S4 method for signature 'nop,operation_sum'
e1 * e2
## S4 method for signature 'operation'
prod(x, ..., na.rm = FALSE)
## S4 method for signature 'operation,operation'
e1 * e2
## S4 method for signature 'numeric,operation'
e1 * e2
## S4 method for signature 'operation,numeric'
e1 * e2
## S4 method for signature 'operation,operation_sum'
e1 * e2
## S4 method for signature 'operation_sum,operation'
e1 * e2
## S4 method for signature 'operation_sum,operation_sum'
e1 * e2
Arguments
e1 |
an operation, layer-like, or |
e2 |
an operation, layer-like, or |
x , ... |
|
na.rm |
ignored |
Details
Multiplication of ggblend operations depends on the types of objects being multiplied:
If you multiply an operation with an operation, they are merged into a single operation that applies each operation in sequence.
If you multiply an operation with a layer-like object, that operation is applied to the layer, returning a new layer-like object.
If you multiply an operation by a
numeric()
n, a new operation that repeats the input operation is n times is returned.
Value
An operation.
Examples
library(ggplot2)
# multiplying operations by numerics repeats them...
adjust(color = "red") * 2
# multiplying operations together chains (or merges) them
adjust(color = "red") * adjust(linewidth = 2)
# multiplication obeys 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
data.frame(x = 1:10) |>
ggplot(aes(x = x, y = x)) +
geom_line(linewidth = 2) * op
[Package ggblend version 0.1.0 Index]