| Title: | Label Data Using a YAML Codebook |
|---|---|
| Description: | A light-weight framework for labeling coded data using a codebook saved as YAML text file. |
| Authors: | Nick Williams [aut, cre] (ORCID: <https://orcid.org/0000-0002-1378-4831>) |
| Maintainer: | Nick Williams <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-23 09:02:05 UTC |
| Source: | https://github.com/nt-williams/codebreak |
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)## ------------------------------------------------ ## 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)