Description Usage Arguments Details Value Note Examples
Convert factor columns in a data.frame to characters.
1 | dfCharacterize(df, only = c(), ignore = c())
|
df |
A data.frame. |
only |
A vector of column names. Only convert these columns to characters. |
ignore |
A vector of column names. Do not convert these columns. |
Given a data.frame, convert factor columns to characters. By default, all factor columns are converted, but the user can specify which columns to convert or to not convert.
A data.frame with all factor columns (or only a subset of them if the parameters were set) converted to characters.
a data.frame with factor columns converted to characters.
If any of the names in only
or ignore
are not valid
columns, an error is raised.
Only one of only
or ignore
can be used in a single call.
1 2 3 4 5 6 7 8 9 10 11 12 | df <- data.frame(a = 1:3, b = letters[1:3], c = LETTERS[1:3],
stringsAsFactors = TRUE)
str(df)
str(dfCharacterize(df))
str(dfCharacterize(df, only = "b"))
str(dfCharacterize(df, ignore = "b"))
str(dfCharacterize(df, ignore = c("b", "c")))
str(dfCharacterize(df, only = c("a")))
# The following examples result in errors
## Not run: str(dfCharacterize(df, only = c("z")))
## Not run: str(dfCharacterize(df, only = "b", ignore = "c"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.