Description Usage Arguments Value Examples
View source: R/numberForLevels.R View source: R/numbersForLevels.R
numberForLevels takes as input a column (dfCol
), a character vector containing the levels of the column, and a numeric vector containing the numbers to be assigned to these levels and returns a one column data.frame object with each entry of the original column replaced by the number corresponding to the respective level.
1 | numberForLevels(dfCol, vec1, vec2)
|
dfCol |
a column of a data.frame object whose levels have to be numbered. Note that this is not a character string but the column itself (refer to examples) |
vec1 |
a vector of class character containing the levels in column |
vec2 |
a vector containing the values to be assigned to each level in |
numberForLevels returns a data.frame object containing one column where each entry of the original column is replaced by the number assigned for the respective level. NA column entries stay unaffected.
1 2 3 | numberForLevels(table[,"col1"], c("a","b","c"),c(1:3))
numberForLevels(warpbreaks[,"tension"],c("L","M","H"),c(1,5,10))
numberForLevels(iris[,"Species"],c("setosa", "versicolor", "virginica"),c(101,102,103))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.