as_base_data_frame2 {labelr}R Documentation

Convert Augmented Data Frame to Base R Data Frame with Alternate Defaults

Description

as_base_data_frame2 noisily converts an augmented data.frame to a Base R data.frame, with any factors converted to character vectors, and any irregular values (see irregular2()) converted to NA.

Usage

as_base_data_frame2(data, fact.to.char = TRUE, irreg.to.na = TRUE)

adf2(data, fact.to.char = TRUE, irreg.to.na = TRUE)

Arguments

data

a data.frame object.

fact.to.char

coerce all factor variables to character variables.

irreg.to.na

convert all irregular values (see irregular2v()) to NA.

Details

Note: adf2 is a compact alias for as_base_data_frame: they do the same thing, and the former is easier to type

as_base_data_frame2 is a variant of as_base_data_frame with different default values for fact.to.char and irreg.to.na. Whereas both of these default to FALSE in as_base_data_frame, they both default to TRUE in as_base_data_frame2. This is the only difference between the two functions. As such, as_base_data_frame2 is intended as a simple shortcut to save typing if one prefers to reverse these default logical argument values.

Value

a data.frame object with any additional classes removed.

Examples

iris_tib <- tibble::as_tibble(iris)
class(iris_tib)
iris_tib$Sepal.Length[1] <- Inf
head(iris_tib, 1)
iris_df <- as_base_data_frame2(iris_tib)
class(iris_df)
sapply(iris_df, class)
head(iris_df, 1)

[Package labelr version 0.1.7 Index]