wh_dict {cleandata}R Documentation

Create Data Dictionary from Data Warehouse

Description

Stacks part of a data frame and repeat the other columns to fit the result of stacking. Optionally records the result into a log file.

Usage

wh_dict(x, attr, value)

Arguments

x

The data frame

attr

The index of the column in x to be explained.

value

The index of the column in x as the explanation in the Keys column of the dictionary.

Value

A 2-column data frame, in which the Keys column stores the explanation of the values in x[, attr].

Warning

x can only be a data frame. Don't pass a vector to it.

See Also

inspect_map, encode

Examples

# refer to vignettes if you want to use log files
message('refer to vignettes if you want to use log files')

# building a data frame
A <- c('i', 'j', 'i', 'k', 'j')
B <- as.factor(c('x', 'y', 'x', 'z', 'y'))
C <- 1:5
df <- data.frame(A, B, C)
print(df)

# encoding
dict <- wh_dict(df, attr = 'B', value = 'A')
print(dict)

[Package cleandata version 0.3.0 Index]