Last active
October 7, 2021 14:03
-
-
Save andrigerber/bdc97455665da759e0090b9a458fcad3 to your computer and use it in GitHub Desktop.
Codebook generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
manual instruction: https://www.youtube.com/watch?v=gMRwUzuGCQU&ab_channel=PsychProf | |
automated online version: https://opencpu.psych.bio.uni-goettingen.de/ocpu/library/codebook/www/ | |
Cran site: https://cran.r-project.org/web/packages/codebook/index.html | |
Package study: https://journals.sagepub.com/doi/full/10.1177/2515245919838783 | |
formr()package: https://formr.org/documentation#api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Codebook" | |
output: | |
html_document: | |
toc: true | |
toc_depth: 4 | |
toc_float: true | |
code_folding: 'hide' | |
self_contained: true | |
pdf_document: | |
toc: yes | |
toc_depth: 4 | |
latex_engine: xelatex | |
--- | |
```{r setup} | |
knitr::opts_chunk$set( | |
warning = TRUE, # show warnings during codebook generation | |
message = TRUE, # show messages during codebook generation | |
error = TRUE, # do not interrupt codebook generation in case of errors, | |
# usually better for debugging | |
echo = TRUE # show R code | |
) | |
ggplot2::theme_set(ggplot2::theme_bw()) | |
pander::panderOptions("table.split.table", Inf) | |
``` | |
We collected the following data. | |
```{r codebook} | |
# omit the following lines, if your missing values are already properly labelled | |
codebook_data <- detect_missing(codebook_data, | |
only_labelled = TRUE, # only labelled values are autodetected as | |
# missing | |
negative_values_are_missing = FALSE, # negative values are missing values | |
ninety_nine_problems = TRUE, # 99/999 are missing values, if they | |
# are more than 5 MAD from the median | |
) | |
# If you are not using formr, the codebook package needs to guess which items | |
# form a scale. The following line finds item aggregates with names like this: | |
# scale = scale_1 + scale_2R + scale_3R | |
# identifying these aggregates allows the codebook function to | |
# automatically compute reliabilities. | |
# However, it will not reverse items automatically. | |
codebook_data <- detect_scales(codebook_data) | |
# Does your dataset have a name that is not reflected in the file name? | |
# Uncomment the line below and change the name | |
# metadata(codebook_data)$name <- "My Awesome Dataset" | |
codebook(codebook_data) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment