trim_cons_runs | R Documentation |
Finds the start and end points of consecutive runs of a value in the beginning and end of a vector.
trim_cons_runs(x, val, head = 0.1, tail = 0.9, n_consec = 4)
x |
The vector |
val |
The value for which to find consecutive runs |
head |
(Proportion between 0 and 1, default = 0.1) The beginning portion of the vector in which to look for consecutive missing values |
tail |
(Proportion between 0 and 1, default = 0.9) The end portion of the vector in which to look for consecutive missing values |
n_consec |
The number of consecutive values which constitutes a 'long' run (default = 4) |
A list of start and end points of a vector to remove heavily weighted heads and tails containing continuous runs of a value (likely denoting missing)
## Not run:
x <- rbinom(100, size=1, prob=0.5)
trunc <- trim_cons_runs(x, 1, n_consec=4)
trunc_x <- x[trunc$start:trunc$end]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.