Extract a list containing the variable labels, value labels and any available information about missing values.
getMetadata(x, save = FALSE, OS = "Windows", ...)
A path to a file, or a tibble object
Boolean, save an .R file in the same directory
The target operating system, for the eol - end of line separator, if saving the file
Additional arguments for this function (internal uses only)
A list containing all variables, their corresponding variable labels and value labels, and (if applicable) missing values if imported and found.
This function reads an XML file containing a DDI codebook version 2.5, or an SPSS file and returns a list containing the variable labels, value labels, plus some other useful information.
It is also possible to extract a limited information from a Stata file, but especially the missing values are not yet imported by package haven.
It additionally attempts to automatically detect a type for each variable:
cat : |
categorical |
num : |
numerical |
numcat : |
numerical variable with very few values (ex. number of children) |
By default, this function extracts the metadata into an R list object, but when the argument
save
is activated, the argument OS
(case insensitive) can be either:
"Windows"
(default), or "Win"
,
"MacOS"
, "Darwin"
, "Apple"
, "Mac"
,
"Linux"
.
The end of line separator changes only when the target OS is different from the running OS.
For the moment, only DDI version 2.5 (Codebook) is supported, but DDI version 3.2 (Lifecycle) is planned to be implemented.