The function attempts to change vector class from factor to integer, double or character.

defactorize(x)

Arguments

x

A factor.

Value

A vector of equivalent length of class numeric, integer or character.

Details

The function tries to handle factors of unknown content by attempting to apply different classes and looking for warnings.

Warning

The function disregards levels information available in vectors of the factor class.

Examples

defactorize(as.factor(c("a", "b")))
#> [1] "a" "b"
defactorize(as.factor(c("a", "b", runif(n = 10))))
#> [1] 11 12 2 10 7 3 1 5 6 4 8 9