View source: R/20-api-generics.R
| fapply | R Documentation |
fapply() is an S3 generic for applying functions over immutable
structures with type-specific dispatch.
fapply(X, FUN, ...)
X |
Object to apply over. |
FUN |
Function to apply. |
... |
Method-specific arguments. |
fapply() returns a new object and preserves class semantics.
Method signatures:
fapply.flexseq(X, FUN, ..., preserve_custom_monoids = TRUE)
fapply.priority_queue(X, FUN, ..., preserve_custom_monoids = TRUE)
fapply.ordered_sequence(X, FUN, ..., preserve_custom_monoids = TRUE)
fapply.interval_index(X, FUN, ..., preserve_custom_monoids = TRUE)
For priority_queue, ordered_sequence, and interval_index,
FUN receives structured fields (value plus metadata) and should return the
new payload value only; ordering metadata is preserved. The name argument is
optional: callbacks that only take value/metadata also work.
If supported by the method, preserve_custom_monoids = TRUE keeps added user
monoids; FALSE rebuilds with required structural monoids only.
Method-dependent result.
flexseq(), priority_queue(), ordered_sequence(), interval_index()
x <- flexseq("a", "b", "c")
fapply(x, toupper)
q <- priority_queue(one = "a", two = "b", priorities = c(2, 1))
fapply(q, function(value, priority, name) paste0(value, priority))
o <- ordered_sequence(one = "a", two = "b", keys = c(2, 1))
fapply(o, function(value, key, name) paste0(value, "_", key))
ix <- interval_index(one = "a", two = "b", start = c(1, 3), end = c(2, 4))
fapply(ix, function(value, start, end, name) paste0(value, "[", start, ",", end, "]"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.