as.num0: Convert a factor to numeric values starting from 0

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 in the range from 0 to the number of levels minus one. 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 argument is converted to a numeric representation using as.numeric. The resulting values are reduced by 1 if v is a factor, to force them into the range between 0 and nlevels(v)-1.

Value

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

Author(s)

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

See Also

as.numchar

Examples

1
2

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