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"
),
V5 = list(
label = "Political party reference",
type = "char",
txt = "When the respondent indicated his political party reference, his/her
open response was recoded on a scale of 1-99 with parties with a
left-wing orientation coded on the low end of the scale and parties with
a right-wing orientation coded on the high end of the scale. Categories
90-99 were reserved miscellaneous responses."
)))
if (FALSE) {
exportDDI(codeBook, file = "codebook.xml")
# using a namespace
exportDDI(codeBook, file = "codebook.xml", xmlns = "ddi")
}
Run the code above in your browser using DataLab