convertToLevels: convertToLevels

Description Usage Arguments Value Examples

View source: R/convertToLevels.R

Description

convertToLevels takes as input a column (dfCol), the allowed number of levels (numLevels) for the column, and the number of class divisions (numBreaks) and casts the numeric entries of the column to factor classes. If the column dfCol is already of class factor then the column is returned as it is (see example 2 below).

Usage

1
convertToLevels(dfCol, numLevels, numBreaks)

Arguments

dfCol

a column of a data.frame object whose entries have to be cast into factor classes. Note that this is not a character string but the column itself (refer to examples).

numLevels

an integer indicating the allowed number of different numeric values.

numBreaks

an integer indicating the number of class divisions (or exact boundaries) that should be taken.

Value

convertToLevels returns an object of class factor which contains the newly created levels (factor classes) from the entries in the column dfCol.

Examples

1
2
convertToLevels(iris[,"Sepal.Length"],4,5)
convertToLevels(iris[,"Species"],3,5)

lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.