reassign | R Documentation |
reassign
Transforms a vector or matrix (mode character or numerical) into an integer object with the same dimension as the input object, with values on the range from 1:length(unique(x)). For an input vector x1, an integer vector x2 is returned with the following properties: (1) x2 equivalency relations of x2 are identical to those in x1 (2) sum(x2) <= sum(x1), for any x1 == abs(x1). (3) unique(x2x1>0) == 1:length(unique(x1x1>0)); if ignore0=FALSE, then unique(x2) == 1:length(unique(x1))
If x is a matrix then x is coerced to a vector and then coerced back to a matrix before returning.
reassign(x, ignore0 = T)
x |
vector or matrix |
ignore0 |
logical indicating if zeros should be ignored. Default true. |
integer vector if x is a vector; integer matrix if x is a matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.