labelled_integer {edstan} | R Documentation |
Transform a vector into consecutive integers
Description
This takes vector and transforms it into a vector of consecutive integers, which has a lowest value of one, a maximum value equal to the number of unique values, and no gaps.
Usage
labelled_integer(x = vector())
Arguments
x |
A vector, which may be numeric, string, or factor. |
Value
A vector of integers corresponding to entries in x
.
The lowest value will be 1, and the greatest value will equal the number of
unique elements in x
.
The elements of the recoded vector are named according to the original
values of x
.
The result is suitable for the ii
and jj
options for
irt_data
.
Examples
x <- c("owl", "cat", "pony", "cat")
labelled_integer(x)
y <- as.factor(x)
labelled_integer(y)
z <- rep(c(22, 57, 13), times = 2)
labelled_integer(z)
[Package edstan version 1.1.0 Index]