Skip to contents

Did you create aggregates of items like this scale <- scale_1 + scale_2R + scale_3R? If you run this function on a dataset, it will detect these relationships and set the appropriate attributes. Once they are set, the codebook package can perform reliability computations for you.

Did you create aggregates of items like this scale <- scale_1 + scale_2R + scale_3R? If you run this function on a dataset, it will detect these relationships and set the appropriate attributes. Once they are set, the codebook package can perform reliability computations for you.

Usage

detect_scales(data, quiet = FALSE)

detect_scales(data, quiet = FALSE)

Arguments

data

the data frame

quiet

defaults to false. Suppresses messages about found items.

Examples

bfi <- data.frame(matrix(data = rnorm(300), ncol = 3))
names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3")
bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")])
bfi <- detect_scales(bfi)
#> 3 bfi_e items connected to scale
bfi$bfi_e
#>   [1]  0.68249929  0.77928889 -1.03398789  0.24238137  0.41108163  0.10804157
#>   [7] -0.56779166  0.09721003 -1.66922283 -0.45429517  0.17750418 -0.87430768
#>  [13] -0.17472868  0.23680844 -0.47623162  0.45740618  0.46387713  0.89456606
#>  [19] -0.73573798  0.58412309 -0.76562949  0.83910280  0.83225778  0.62808009
#>  [25]  0.30561358 -0.09151848  0.74031423 -0.66943123  0.21972537  0.22164853
#>  [31]  1.35203360  0.34120713 -0.32233926  0.73158080  0.31688055  0.28018593
#>  [37] -0.27610186 -0.64574898 -0.90461595  0.24135359  0.10752722 -0.82755238
#>  [43]  0.25932466 -0.31279482  0.09607748 -1.59163543 -0.12815941  0.62063074
#>  [49]  0.74520853  0.04094594  0.59952548 -0.08642481  0.81854511  0.77670992
#>  [55] -0.06537362 -0.37510175  0.67992387  0.52871967 -1.03568875 -1.30363811
#>  [61]  0.19828320  0.42895503 -0.13062254 -0.32051806  0.43242926 -0.06552491
#>  [67] -0.85728745 -0.59051293  1.28965980 -0.51938666 -1.32629468  0.34616546
#>  [73] -0.07559116  0.58369035 -0.91976184 -0.13099517 -0.67531725  0.39364522
#>  [79] -0.04407500 -0.64801309 -0.15780638 -0.24514966 -1.12287812  0.46228456
#>  [85] -1.16745698 -0.18866174  1.34459574  0.30778443  0.73996007  0.72889848
#>  [91] -0.43522305 -0.02962567  0.12905313 -0.76422008  0.43919957 -0.23828486
#>  [97] -0.45097870  0.32985639  1.30993934 -1.31037685
#> attr(,"scale_item_names")
#> [1] "bfi_e1"  "bfi_e2R" "bfi_e3" 
#> attr(,"label")
#> [1] "aggregate of 3 bfi_e items"
bfi <- data.frame(matrix(data = rnorm(300), ncol = 3))
names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3")
bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")])
bfi <- detect_scales(bfi)
#> 3 bfi_e items connected to scale
bfi$bfi_e
#>   [1] -0.502172218 -0.431879929 -0.495985363 -1.120832852  0.049686067
#>   [6] -0.563059761  1.105095369  0.371067763 -0.607880164 -0.301060799
#>  [11]  0.369429090 -0.138117669  0.541330714  0.256596110  0.661218543
#>  [16] -0.664322719  0.434891800 -0.031779575  0.365696596 -1.306240212
#>  [21] -0.623121950 -0.612711377 -1.106205100  0.614808891 -0.075827088
#>  [26]  0.182669487 -0.451533900 -0.454538313  0.910818570 -0.405420594
#>  [31]  0.233886875 -0.937625452 -0.193737168 -0.228149409  0.687654432
#>  [36]  0.395421746  0.599151407  1.174867760 -0.155523117  1.098220036
#>  [41] -0.456091906 -0.336469935  1.512587955  0.399805250 -0.396619665
#>  [46] -0.269658597 -0.214700479 -0.378173689  0.443365702  0.908733475
#>  [51]  0.052400284  0.242154948  0.149008884  0.209647490  0.356641492
#>  [56]  0.614080058 -0.274160930 -0.084715522 -0.531040879 -0.422708294
#>  [61] -0.470475155 -0.814858208 -0.588315100  1.091467536  0.320599935
#>  [66]  0.996773978 -0.200175736 -0.446062843  0.543623739 -0.167868130
#>  [71] -0.007257087  0.656378028  1.005426062 -0.560318383  0.133006507
#>  [76] -0.188995550 -1.334626037  1.470283416 -0.527778950  0.287272734
#>  [81] -0.306084078 -0.312422337 -0.129541534 -0.525578583 -0.759719946
#>  [86] -1.071909603  0.601158262 -0.297178907 -0.165597041  0.777162680
#>  [91]  1.383476210 -0.256776664  0.041581469 -0.822791525  0.586172987
#>  [96] -0.522463683  0.723380995 -0.679383729  0.379866122 -0.806330625
#> attr(,"scale_item_names")
#> [1] "bfi_e1"  "bfi_e2R" "bfi_e3" 
#> attr(,"label")
#> [1] "aggregate of 3 bfi_e items"