fdfAsInt: Convert 'data.frame' of factors to integers

Description Usage Arguments Value Examples

View source: R/data.frame.R

Description

Converts a data.frame that consists columns of factors into a data.frame consisting of integers. If useLevelNames is FALSE, numbering starts at 0.

Usage

1
  fdfAsInt(x, useLevelNames = T)

Arguments

x

an object of class data.frame

useLevelNames

logical, indicating whether the labels of the levels should be be converted to integers. This only makes sense if the levels are integers stored as characters. e.g. factor(c("3", "2", "3")).

Value

The data.frame with columns converted to integers

Examples

1
2
3
4
5
6
7
8
lets <- as.factor(c("a", "c", "b"))
nums <- as.factor(c("1", "2", "3"))
vars <- as.factor(c("3", "2", "1"))
x <- data.frame(letters = lets, numbers = nums, vars = vars)
fdfAsInt(x, useLevelNames = FALSE)
## Not run: fdfAsInt(x)
fdfAsInt(x[, 2:3])
# returns a data.frame

rjbgoudie/utils.rjbg documentation built on May 27, 2019, 9:13 a.m.