Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/r-utility-factor-numeric.R
This function converts a factor to numeric values which have the same character representation as the original factor labels (rather than consecutive integers from 1). It is used in examples presented in the book Cichosz, P. (2015): Data Mining Algorithms: Explained Using R. See Appendix B or http://www.wiley.com/go/data_mining_algorithms for more details.
1 | as.numchar(v)
|
v |
a vector or list of a factor type or another type that can be converted to numeric |
The input factor is assumed to have labels that can be
converted to numbers. It is converted to a character representation using
as.character
(yielding factor labels) and then to a numeric
representation using as.numeric
.
If v
is a factor then as.numeric(as.character(v))
, otherwise as.numeric(v)
.
Pawel Cichosz <p.cichosz@elka.pw.edu.pl>
1 2 | as.numchar(as.factor(0:9))
as.numchar(as.factor(1:10))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.