| Codebook | R Documentation |
Decode and label data using a codebook saved as a YAML text file.
pathPath to a YAML text file.
codebookThe codebook.
new()Import a YAML codebook
Codebook$new(path = "codebook.yml")
pathThe path to the YAML codebook.
A new 'Codebook' object.
Codebook$new(system.file("codebook.yml", package = "codebreak"))
decode()Decode data.
Codebook$decode( data, label = FALSE, as_labelled = FALSE, .include = NULL, .exclude = NULL )
dataThe data to decode.
labelShould column names also be renamed according to codebook labels?
as_labelledShould the codebook be applied using the labelled package?
.includeAn optional character vector of column names to apply the codebook to.
.excludeAn optional character vector of column names to not apply
the codebook to. Ignored if .include is specified.
An updated copy of data.
ex <- data.frame(
x = c(1, 2, 5, 3, 4),
y = c(0, 1, 1, 0, 1),
z = rnorm(5),
w = c(1, 1, 0, 1, 1)
)
cb <- Codebook$new(system.file("codebook.yml", package = "codebreak"))
cb$decode(ex)
label()Label data.
Codebook$label(data, as_labelled = FALSE, .include = NULL, .exclude = NULL)
dataThe data to label.
as_labelledShould the codebook labels be applied using the labelled package?
.includeAn optional character vector of column names to apply the codebook to.
.excludeAn optional character vector of column names to not apply
the codebook to. Ignored if .include is specified.
ex <- data.frame(
x = c(1, 2, 5, 3, 4),
y = c(0, 1, 1, 0, 1),
z = rnorm(5),
w = c(1, 1, 0, 1, 1)
)
cb <- Codebook$new(system.file("codebook.yml", package = "codebreak"))
cb$label(ex)
print()Codebook$print()
## ------------------------------------------------
## Method `Codebook$new`
## ------------------------------------------------
Codebook$new(system.file("codebook.yml", package = "codebreak"))
## ------------------------------------------------
## Method `Codebook$decode`
## ------------------------------------------------
ex <- data.frame(
x = c(1, 2, 5, 3, 4),
y = c(0, 1, 1, 0, 1),
z = rnorm(5),
w = c(1, 1, 0, 1, 1)
)
cb <- Codebook$new(system.file("codebook.yml", package = "codebreak"))
cb$decode(ex)
## ------------------------------------------------
## Method `Codebook$label`
## ------------------------------------------------
ex <- data.frame(
x = c(1, 2, 5, 3, 4),
y = c(0, 1, 1, 0, 1),
z = rnorm(5),
w = c(1, 1, 0, 1, 1)
)
cb <- Codebook$new(system.file("codebook.yml", package = "codebreak"))
cb$label(ex)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.