convertFromFactor: Convert factor variable to numeric or character variable.

Description Usage Arguments Details Value See Also Examples

View source: R/convertFromFactor.R

Description

Convert factor variable to numeric or character variable.

Usage

1
2
convertFromFactor(data = NULL, numeric = c(""), character = c(""),
  mode = c("automatic", "only_specified", "all_character", "all_numeric"))

Arguments

data

a data.frame which contains factor variables.

numeric

a character vector specifying variable names to be converted into numeric variables.

character

a character vector specifying variable names to be converted into character variables.

mode

a character vector specifying converting mode. See details and the default is ‘only_specified’.

Details

This function convert factor variable to numeric or character variable. In ‘automatic’ mode, all variables not specified by numeric or character arguments are converted into numeric or character automatically. Explicitly specified variables are converted as specified. In ‘only_specified’ mode, variables specified by numeric argument is converted into numeric variables, and the character is conveted into character variables. When converted into numeric variable, NAs can be produced for incompatible data with warnings. In ‘all_character’, and ‘all_numeric’ modes, all factor variables are converted into character or numeric variables, respectively.

Value

a converted data.frame.

See Also

showContents, listNumericIncompatibility

Examples

1
2
3
4
5
6
7
8
a <- factor(rnorm(5))
b <- c("a", "b", "c", "d", "e")
c <- c("1", "2", "3", "4", NA)
d <- c("1", "2", "3", "4", ".")
dat <- data.frame(a,b,c,d)
dat2 <- convertFromFactor(dat)
dat3 <- convertFromFactor(dat, numeric=c("d"))
dat4 <- convertFromFactor(dat, mode="all_character")

epifit documentation built on May 29, 2017, 3:43 p.m.