codebook: Generate rmarkdown codebook

Description Usage Arguments Examples

View source: R/codebook.R

Description

Pass a data frame to this function to make a codebook for that dataset. If the dataset has metadata (attributes) set on its variables, these will be used to make the codebook more informative. Examples are item, value, and missing labels. Data frames imported via haven::read_dta(), haven::read_sav(), or from formr.org will have these attributes in the right format. By calling this function inside a knitr code chunk, the codebook will become part of the document you are generating.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
codebook(
  results,
  reliabilities = NULL,
  survey_repetition = c("auto", "single", "repeated_once", "repeated_many"),
  detailed_variables = TRUE,
  detailed_scales = TRUE,
  survey_overview = TRUE,
  missingness_report = TRUE,
  metadata_table = TRUE,
  metadata_json = TRUE,
  indent = "#"
)

Arguments

results

a data frame, ideally with attributes set on variables

reliabilities

a named list with one entry per scale and one or several printable reliability computations for this scale. if NULL, computed on-the-fly using compute_reliabilities

survey_repetition

defaults to "auto" which is to try to determine the level of repetition from the "session" and "created" variables. Other values are: single, repeated_once, repeated_many

detailed_variables

whether to print a graph and summary for each variable

detailed_scales

whether to print a graph and summary for each scale

survey_overview

whether to print an overview of survey entries, durations (depends on presence of columns session, created, modified, ended, expired)

missingness_report

whether to print a missingness report. Turn off if this gets too complicated and you need a custom solution (e.g. in case of random missings).

metadata_table

whether to print a metadata table/tabular codebook.

metadata_json

whether to include machine-readable metadata as JSON-LD (not visible)

indent

add # to this to make the headings in the components lower-level. defaults to beginning at h2

Examples

1
2
3
4
5
6
7
# will generate figures in a temporary directory
## Not run: 
data("bfi")
bfi <- bfi[, c("BFIK_open_1", "BFIK_open_1")]
md <- codebook(bfi, survey_repetition = "single", metadata_table = FALSE)

## End(Not run)

Example output

dev.new(): using pdf(file="Rplots1.pdf")
dev.new(): using pdf(file="Rplots2.pdf")
dev.new(): using pdf(file="Rplots3.pdf")
dev.new(): using pdf(file="Rplots4.pdf")
dev.new(): using pdf(file="Rplots5.pdf")
dev.new(): using pdf(file="Rplots6.pdf")
dev.new(): using pdf(file="Rplots7.pdf")
dev.new(): using pdf(file="Rplots8.pdf")
dev.new(): using pdf(file="Rplots9.pdf")
dev.new(): using pdf(file="Rplots10.pdf")
dev.new(): using pdf(file="Rplots18.pdf")
dev.new(): using pdf(file="Rplots19.pdf")
dev.new(): using pdf(file="Rplots20.pdf")
dev.new(): using pdf(file="Rplots21.pdf")
dev.new(): using pdf(file="Rplots22.pdf")
dev.new(): using pdf(file="Rplots23.pdf")
dev.new(): using pdf(file="Rplots24.pdf")
dev.new(): using pdf(file="Rplots11.pdf")
dev.new(): using pdf(file="Rplots12.pdf")
dev.new(): using pdf(file="Rplots13.pdf")
dev.new(): using pdf(file="Rplots14.pdf")
dev.new(): using pdf(file="Rplots15.pdf")
dev.new(): using pdf(file="Rplots16.pdf")
dev.new(): using pdf(file="Rplots17.pdf")
No missing values.
dev.new(): using pdf(file="Rplots25.pdf")
dev.new(): using pdf(file="Rplots26.pdf")
dev.new(): using pdf(file="Rplots27.pdf")
dev.new(): using pdf(file="Rplots28.pdf")
dev.new(): using pdf(file="Rplots29.pdf")
dev.new(): using pdf(file="Rplots30.pdf")
dev.new(): using pdf(file="Rplots31.pdf")
dev.new(): using pdf(file="Rplots32.pdf")
dev.new(): using pdf(file="Rplots33.pdf")
dev.new(): using pdf(file="Rplots34.pdf")

codebook documentation built on July 1, 2020, 10:28 p.m.