dataDict: Create a Data Dictionary

Description Usage Arguments Details Value Examples

View source: R/Data_Dictionary.R

Description

Create a data dictionary object which holds information on the columns of a data.frame-like object.

Usage

1
dataDict(df, tableMode = "lazy", verbose = Inf)

Arguments

df

The data.frame-like object to calculate information for (should be a name, not an expression).

tableMode

What mode to use for tabulating each column (see details for more) (character/logical scalar).

verbose

How verbose you want the function to be (higher prints more information) (integer scalar).

Details

The df parameter should be the name of a data.frame-like object, as opposed to an expression. E.g. call the function as dataDict(mtcars), instead of dataDict(as_tibble(mtcars)). This will allow for more functionality, and will help avoid errors, especially when lazy table mode is active. If you want to pass an expression, simple ones should work, but do so at your own risk.

tableMode can be one of three values: c(TRUE, FALSE, "lazy"). Lazy table mode means that columns are not tabulated until requested. When they are tabulated, they can be done only when accessed (tableMode = "lazy"), or all together up front (tableMode = true). This setting can be deactivated entirely (tableMode = FALSE), but this is not suggested. This setting is useful since tabulation can take a long time for large datasets.

If verbose > 0 (or verbose != FALSE), a message will be printed out when lazy table mode is active, as well as when df is passed as an expression. If verbose > 1, a message will be printed out saying what object the dataDict is based on.

Value

A dataDict object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dd1 <- dataDict(mtcars)
dd2 <- dataDict(mtcars, tableMode = "lazy")
dd3 <- dataDict(mtcars, tableMode = TRUE)
dd5 <- dataDict(mtcars, tableMode = FALSE)
dd4 <- dataDict(mtcars, tableMode = "lazy", verbose = 0)
dd4 <- dataDict(mtcars, tableMode = TRUE, verbose = 0)
dd4 <- dataDict(mtcars, tableMode = FALSE, verbose = 0)

# The line below works, since the expression is rather simple, but should be avoided
# It is better to declare use something like: `df <- as_tibble(mtcars); dd <- dataDict(df)`
dd <- dataDict(tibble::as_tibble(mtcars))

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.