import_raw {eatGADS} | R Documentation |
Import R data frame with explicit meta data sheets
Description
Function to import a data.frame
object for use in eatGADS
while adding explicit variable and value meta information through
separate data.frames
.
Usage
import_raw(df, varLabels, valLabels = NULL, checkVarNames = TRUE)
Arguments
df |
A |
varLabels |
A |
valLabels |
A |
checkVarNames |
Should variable names be checked for violations of |
Details
The argument varLables
has to contain exactly two variables, namely varName
and varLabel
. valLables
has
to contain exactly four variables, namely varName
, value
, valLabel
and missings
. The column value
can only contain numerical values. The column missings
can only contain the values "valid"
and "miss"
.
Variables of type factor
are not supported in any of the data.frames
.
Value
Returns a list with the actual data dat
and with all meta information in long format labels
.
Examples
dat <- data.frame(ID = 1:5, grade = c(1, 1, 2, 3, 1))
varLabels <- data.frame(varName = c("ID", "grade"),
varLabel = c("Person Identifier", "School grade Math"),
stringsAsFactors = FALSE)
valLabels <- data.frame(varName = c("grade", "grade", "grade"),
value = c(1, 2, 3),
valLabel = c("very good", "good", "sufficient"),
missings = c("valid", "valid", "valid"),
stringsAsFactors = FALSE)
gads <- import_raw(df = dat, varLabels = varLabels, valLabels = valLabels, checkVarNames = FALSE)
# Inspect Meta data
extractMeta(gads)
# Extract Data
dat <- extractData(gads, convertLabels = "character")