lt_eq_gt | R Documentation |
Recode variable based on whether it is less than, equal to, or greater than a specified comparison value
lt_eq_gt(x, compare_to, vals = 1:3)
x |
a numeric vector. The variable to recode. |
compare_to |
a single numeric value. The comparison value. |
vals |
a vector of length 3. Defaults to |
Returns vals[1]
if x < compare_to
, vals[2]
if
x == compare_to
, and vals[3]
if x > compare_to
. The
function is vectorized so that if length(x) > 1
each x[i]
is
compared to k
and recoded.
y1 <- 1:10
y2 <- lt_eq_gt(y1, compare_to = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.