wh_dict {cleandata} | R Documentation |
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.
wh_dict(x, attr, value)
x |
The data frame |
attr |
The index of the column in |
value |
The index of the column in |
A 2-column data frame, in which the Keys
column stores the explanation of the values in x[, attr]
.
x
can only be a data frame. Don't pass a vector to it.
# 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)