replace_backtraced: Replace chains of values

Description Usage Arguments Details Value Examples

Description

replace_backtraced replaces chains of backtraced values within a vector.

Usage

1
replace_backtraced(x, backtrace, replace_val)

Arguments

x

A vector in which a values are to be replaced.

backtrace

An integer vector of the same length as x, with values of 1 if the entry belongs to a chain, and 0 otherwise. As returned by backtrace_values().

replace_val

New value for all entries belonging to a chain of backtraced values.

Details

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().

Value

A copy of vector x in which all elements that belong to a chain have been replaced by the value replace.

Examples

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")

dschoenig/IDENTcc documentation built on May 16, 2019, 4:07 a.m.