# NOT RUN {
codeBook <- list(dataDscr = list(
ID = list(
label = "Questionnaire ID",
type = "num",
measurement = "interval"
),
V1 = list(
label = "Label for the first variable",
labels = c(
"No" = 0,
"Yes" = 1,
"Not applicable" = -97,
"Not answered" = -99),
na_values = c(-99, -97),
type = "cat",
measurement = "nominal"
),
V2 = list(
label = "Label for the second variable",
labels = c(
"Very little" = 1,
"Little" = 2,
"So, so" = 3,
"Much" = 4,
"Very much" = 5,
"Don't know" = -98),
na_values = c(-98),
type = "cat",
measurement = "ordinal"
),
V3 = list(
label = "Label for the third variable",
labels = c(
"First answer" = "A",
"Second answer" = "B",
"Don't know" = -98),
na_values = c(-98),
type = "cat",
measurement = "nominal"
),
V4 = list(
label = "Number of children",
labels = c(
"Don't know" = -98,
"Not answered" = -99),
na_values = c(-99, -98),
type = "numcat",
measurement = "ratio"
)))
# }
# NOT RUN {
# IMPORTANT:
# make sure to set the working directory to a directory with read/write permissions
# setwd("/path/to/read/write/directory")
# path.to.csv <- file.path(system.file(package = "DDIwR"), "data", "test.csv.gz")
setupfile(codeBook)
# if the csv data file is available
setupfile(codeBook, csv="/path/to/csv/file.csv")
# generating a specific type of setup file
setupfile(codeBook, file = "codeBook.do") # type = "Stata" is unnecessary
# other types of possible utilizations, using paths to specific files
# an XML file containing a DDI metadata object
setupfile("/path/to/the/metadata/file.xml", csv="/path/to/csv/file.csv")
# or in batch mode, specifying entire directories
setupfile("/path/to/the/metadata/directory", csv="/path/to/csv/directory")
# }
Run the code above in your browser using DataLab