Description Usage Arguments Details Value See Also Examples
View source: R/convertFromFactor.R
Convert factor variable to numeric or character variable.
1 2 |
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’. |
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.
a converted data.frame.
showContents
, listNumericIncompatibility
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.