Learning to Create a Codebook

Loading Packages

if(!require(haven)){
  install.packages("haven", dependencies = TRUE)
  require(haven)
  }
Loading required package: haven
if(!require(tidyverse)){
  install.packages("tidyverse", dependencies = TRUE)
  require(tidyverse)
  }
Loading required package: tidyverse
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0      ✔ purrr   1.0.1 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.3.0      ✔ stringr 1.5.0 
✔ readr   2.1.3      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
if(!require(summarytools)){
  install.packages("summarytools", dependencies = TRUE)
  require(summarytools)
  }
Loading required package: summarytools
Warning in fun(libname, pkgname): couldn't connect to display ":0"
system might not have X11 capabilities; in case of errors when using dfSummary(), set st_options(use.x11 = FALSE)

Attaching package: 'summarytools'
The following object is masked from 'package:tibble':

    view

Import Data

dataset <- read_sav ("https://osf.io/kd4ej/download")

Codebook

(dataset %>%
  select(CoinFlip, FFM_13, Potter26) -> dataset.three)
# A tibble: 122 × 3
   CoinFlip  FFM_13                         Potter26      
   <dbl+lbl> <dbl+lbl>                      <dbl+lbl>     
 1 1 [Heads] 5 [Agree Strongly]             6 [Werewolves]
 2 2 [Tails] 2 [Disagree a little]          3 [Merpeople] 
 3 1 [Heads] 4 [Agree a little]             6 [Werewolves]
 4 2 [Tails] 5 [Agree Strongly]             7 [Trolls]    
 5 1 [Heads] 5 [Agree Strongly]             4 [Ghosts]    
 6 2 [Tails] 4 [Agree a little]             6 [Werewolves]
 7 2 [Tails] 3 [Neither agree nor diasgree] 3 [Merpeople] 
 8 1 [Heads] 5 [Agree Strongly]             4 [Ghosts]    
 9 1 [Heads] 5 [Agree Strongly]             4 [Ghosts]    
10 1 [Heads] 5 [Agree Strongly]             6 [Werewolves]
# … with 112 more rows

Make the codebook

print(dfSummary(dataset.three, graph.magnif = .75), method = 'render')
Warning in png(png_loc <- tempfile(fileext = ".png"), width = 150 *
graph.magnif, : unable to open connection to X11 display ''

Warning in png(png_loc <- tempfile(fileext = ".png"), width = 150 *
graph.magnif, : unable to open connection to X11 display ''

Warning in png(png_loc <- tempfile(fileext = ".png"), width = 150 *
graph.magnif, : unable to open connection to X11 display ''

Data Frame Summary

dataset.three

Dimensions: 122 x 3
Duplicates: 84
No Variable Label Stats / Values Freqs (% of Valid) Graph Valid Missing
1 CoinFlip [haven_labelled, vctrs_vctr, double] Flip a coin. Is it heads or tails?
Min : 1
Mean : 1.3
Max : 2
1:83(70.3%)
2:35(29.7%)
118 (96.7%) 4 (3.3%)
2 FFM_13 [haven_labelled, vctrs_vctr, double] I see Myself as Someone Who..... - Is a reliable worker
Mean (sd) : 4.4 (0.7)
min ≤ med ≤ max:
2 ≤ 5 ≤ 5
IQR (CV) : 1 (0.2)
2:2(2.0%)
3:8(8.2%)
4:32(32.7%)
5:56(57.1%)
98 (80.3%) 24 (19.7%)
3 Potter26 [haven_labelled, vctrs_vctr, double] Which of the following would you most like to study?
Mean (sd) : 3.9 (1.7)
min ≤ med ≤ max:
1 ≤ 4 ≤ 7
IQR (CV) : 2 (0.4)
1:14(14.1%)
2:4(4.0%)
3:19(19.2%)
4:23(23.2%)
5:16(16.2%)
6:22(22.2%)
7:1(1.0%)
99 (81.1%) 23 (18.9%)

Generated by summarytools 1.0.1 (R version 4.2.2)
2023-02-15