Encode a vector x to a factor and then to a numeric value. It's a simple shortcut for as.numeric(factor(x, ...))

Nf(x, ...)

Arguments

x

a vector of data, usually taking a small number of distinct values.

...

the dots are passed on to factor

Value

numeric vector

Author

Andri Signorell <andri@signorell.net>

See also

N

Examples

x <- LETTERS[10:15]
Nf(x)
#> [1] 1 2 3 4 5 6

# same as ..
as.numeric(factor(x))
#> [1] 1 2 3 4 5 6