dfCharacterize: 'Characterize' data.frame

Description Usage Arguments Details Value Note Examples

Description

Convert factor columns in a data.frame to characters.

Usage

1
dfCharacterize(df, only = c(), ignore = c())

Arguments

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.

Details

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.

Value

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.

Note

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.

Examples

 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"))

anilchalisey/juggleR documentation built on May 9, 2019, 4 a.m.