Convert value-types in an array or matrix (per column) to pre-defined class-values

Share:

Description

This functions converts values in an array or matrix-column to pre-defined class-values. Each unique value in the array or matrix-column is assigned to a class-value in order of occurrence. For a matrix, this process is repeated per column (the user can define which columns). Default pre-defined class-values are -1 to 100.

Usage

1

Arguments

data

an array or matrix containing the values to be converted to class values.

cols

which columns of the matrix need to be converted.

new.classes

user defined class values to be used (re-used in case class types needed exceeds class types defined)

Value

The same array or matrix as the input, but with each value replaced with numerical class values.

Author(s)

Tim Dorscheidt

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.