Description Usage Arguments Value Examples
View source: R/convertToLevels.R
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).
1 | convertToLevels(dfCol, numLevels, numBreaks)
|
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. |
convertToLevels returns an object of class factor which contains the newly created levels (factor classes) from the entries in the column dfCol
.
1 2 | convertToLevels(iris[,"Sepal.Length"],4,5)
convertToLevels(iris[,"Species"],3,5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.