split_vector | R Documentation |
Splits a vector
into a list of vectors based on split points.
split_vector(x, split = "", include = FALSE, regex = FALSE, ...)
x |
A vector with split points. |
split |
A vector of places (elements) to split on or a regular
expression if |
include |
An integer of |
regex |
logical. If |
... |
other arguments passed to |
Returns a list of vectors.
Matthew Flickinger and Tyler Rinker <tyler.rinker@gmail.com>.
https://stackoverflow.com/a/24319217/1000343
loc_split
,
run_split
set.seed(15)
x <- sample(c("", LETTERS[1:10]), 25, TRUE, prob=c(.2, rep(.08, 10)))
split_vector(x)
split_vector(x, "C")
split_vector(x, c("", "C"))
split_vector(x, include = 0)
split_vector(x, include = 1)
split_vector(x, include = 2)
set.seed(15)
x <- sample(1:11, 25, TRUE, prob=c(.2, rep(.08, 10)))
split_vector(x, 1)
## relationship to `loc_split`
all.equal(
split_vector(x, include = 1),
loc_split(x, which(x == ""), names=1:6)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.