Description Usage Arguments Value Author(s) Examples
Reclassify given values of a vector by new values. Note that all values need not to be documented, only the ones that need to be modified.
1 |
x |
A character or numeric vector. |
from |
A vector describing the values to change from, or a matrix of reclassification with two columns (from, to). |
to |
A vector describing the values to change to, or nothing if
|
factor |
Logical, whether to return a factor (default is
|
... |
Additional arguments passed to |
A vector with the same length as x
.
Mathieu Basille basille@ufl.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | (bla <- rep(1:5, 3))
reclass(bla, c(3, 4), c(7, 3))
reclass(bla, c(3, 4), c("a", "b"))
## Conversion as a factor
reclass(bla, c(3, 4), c("a", "b"), factor = TRUE)
(bli <- rep(letters[1:5], 3))
reclass(bli, c("b", "d"), c(1, 2))
## With a matrix of reclassification
(mat <- matrix(c("b", "d", 1, 2), ncol = 2))
reclass(bli, mat)
## Fast computation time on large vectors
blu <- rpois(1e6, 10)
system.time(reclass(blu, c(3, 4), c(7, 3)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.