View source: R/20-api-generics.R
| as_flexseq | R Documentation |
flexseqas_flexseq() is the canonical way to obtain a plain flexseq for full
sequence-style operations.
as_flexseq(x)
x |
Input object. |
For base vectors/lists, this builds a new flexseq preserving element order
and names.
For specialized immutable subclasses (priority_queue,
ordered_sequence, interval_index), this intentionally drops subclass
semantics and returns a plain flexseq.
This is an S3 generic. Notable method behavior:
as_flexseq.flexseq(x) returns x unchanged.
as_flexseq.priority_queue(x) returns payload items.
as_flexseq.ordered_sequence(x) returns payload items.
as_flexseq.interval_index(x) returns payload items.
For advanced types, custom monoids are dropped and the rebuilt flexseq
keeps only structural monoids (.size, .named_count). For
priority_queue, a flexseq of full entry records can be obtained by
composing with as.list(): as_flexseq(as.list(x)). For
ordered_sequence and interval_index, as.list() also returns
payload-only lists, so no direct record-preserving cast is provided.
A plain flexseq.
flexseq(), priority_queue(), ordered_sequence(), interval_index()
x <- as_flexseq(1:3)
x
q <- priority_queue("a", "b", priorities = c(2, 1))
as_flexseq(q)
o <- ordered_sequence("a", "b", keys = c(2, 1))
as_flexseq(o)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.