as.numchar: Convert a factor to numeric values with the same character...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/r-utility-factor-numeric.R

Description

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.

Usage

1

Arguments

v

a vector or list of a factor type or another type that can be converted to numeric

Details

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.

Value

If v is a factor then as.numeric(as.character(v)), otherwise as.numeric(v).

Author(s)

Pawel Cichosz <p.cichosz@elka.pw.edu.pl>

See Also

as.num0

Examples

1
2

42n4/dmr.util documentation built on May 20, 2019, 2:02 p.m.