Description Usage Arguments Details Value Examples
replace_backtraced
replaces chains of backtraced values within a vector.
1 | replace_backtraced(x, backtrace, replace_val)
|
x |
A vector in which a values are to be replaced. |
backtrace |
An integer vector of the same length as |
replace_val |
New value for all entries belonging to a chain of backtraced values. |
Simple convenience function that replaces all entries in a vector x
for
which a matching vector backtrace
contains 1
. Intended for use with
backtrace_values()
.
A copy of vector x
in which all elements that belong to a chain have
been replaced by the value replace
.
1 2 3 4 5 6 7 8 | # A sequence of mortality assessments containing erroneous instances of "Dead"
x <- c("Alive", "Almost dead", "Dead", "Dead", "Dead", "Alive", "Dead",
"Dead", "Alive", "Dead", "Cut and Resprout", "Dead", "Alive")
da_starts <- detect_transitions(x, c("Dead", "Alive"))
da_trace <- backtrace_values(x, "Dead", da_starts)
# Set erroneous entries to "Alive"
replace_backtraced(x, da_trace, "Alive")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.