source("00_packages.R")
## Loading required package: devtools
## Loading required package: usethis
## Loading required package: pacman
## Loading required package: formr
# knit_by_pkgdown <- !is.null(knitr::opts_chunk$get("fig.retina"))

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,
                # TRUE is usually better for debugging
  echo = TRUE  # show R code
)
ggplot2::theme_set(ggplot2::theme_bw())
pander::panderOptions("table.split.table", Inf)

# use multiple processors
plan(multicore)
codebook_data <- readRDS("data/my_soepisv34.rds") %>% select(5:10)
## Warning in gzfile(file, "rb"): cannot open compressed file 'data/
## my_soepisv34.rds', probable reason 'No such file or directory'
## Error in gzfile(file, "rb"): cannot open the connection
codebook_data <- codebook_data %>% 
      codebook::detect_missing(
            only_labelled = FALSE,
            negative_values_are_missing = TRUE,
            ninety_nine_problems = FALSE,
            learn_from_labels = TRUE
            )  %>% 
      detect_scales(codebook_data)
## Error in eval(lhs, parent, parent): object 'codebook_data' not found
# 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(codebook_data)
## Error in codebook(codebook_data): could not find function "codebook"