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.

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(500), ncol = 5)) names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3", "bfi_n1", "bfi_n2") bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")]) bfi <- detect_scales(bfi)
#> 3 bfi_e items connected to scale
#> Warning: bfi_n items found, but no aggregate
bfi$bfi_e
#> [1] 0.8015485778 0.1242008715 1.4111601036 -1.2359843828 0.8755174016 #> [6] 0.9704337425 0.1256702396 0.4579800147 0.1481186619 -0.2613590844 #> [11] -0.0454207511 1.2847818751 0.0969500761 -0.4646285832 0.9872776221 #> [16] 1.0607406147 0.8092427361 -0.3909060260 -0.1631451792 -0.0168259197 #> [21] 0.0379601509 -1.3348544542 -0.3418188349 -0.3469655384 0.2681050820 #> [26] 0.0160450021 0.6795888007 -0.6340680673 -0.9698365999 0.5346686176 #> [31] -1.1772199366 0.5013617944 0.7480301550 0.7210123466 -0.5085987698 #> [36] -0.7530780276 0.7376071929 0.7836556475 0.2392642892 0.9698502499 #> [41] 0.2076311038 0.4118653252 -0.0735040359 0.4506413326 0.2195415811 #> [46] 0.1802557582 -0.2274196804 0.0477936993 -0.8153949023 0.6790446071 #> [51] -1.0123051762 -0.1929429826 0.3603824703 -0.9452471654 -0.2475681063 #> [56] 0.7194436012 -0.2554316310 -0.4332763827 0.8590040320 0.9552586648 #> [61] 0.1924536606 -0.5312016165 1.4697668632 -0.3988861741 -0.0001894151 #> [66] -0.3956289014 0.8160424138 -0.3266707117 -0.1756387935 -0.6017318640 #> [71] 0.1412798858 1.3190123866 0.4557577536 -0.0185777490 0.3302301687 #> [76] -0.1244923341 0.4662560852 -0.6980709833 0.1884465481 0.1645677940 #> [81] 0.6181046675 -0.9340002428 -0.6359859871 -0.3176546090 -0.4788309317 #> [86] 0.2373336437 0.1946028667 0.0456007471 -1.2833583570 0.0641209995 #> [91] 0.0325788440 0.1460103547 1.3553405723 0.6966568876 -0.3455142832 #> [96] 0.1093705621 1.0434134739 0.1010924876 -0.8042213045 -0.4034993055 #> 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(500), ncol = 5)) names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3", "bfi_n1", "bfi_n2") bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")]) bfi <- detect_scales(bfi)
#> 3 bfi_e items connected to scale
#> Warning: bfi_n items found, but no aggregate
bfi$bfi_e
#> [1] -0.194491951 0.599303261 1.361161754 1.210202575 -0.714562458 #> [6] 0.074074287 0.039096102 0.703875680 0.001766981 0.420126472 #> [11] 0.097186704 -0.299350416 -0.110115099 -0.138134406 0.243545579 #> [16] 0.891731006 -0.793210394 0.888058876 -0.054600266 0.167755563 #> [21] 0.940822540 -0.230862032 -0.859446408 -0.601098601 -0.320550995 #> [26] 0.204980824 0.237595906 0.469456438 -0.236321642 -0.686148562 #> [31] -0.600329415 -0.101751952 0.379019532 -0.649607631 -0.713580039 #> [36] 0.139134092 -1.595526920 1.584097982 -0.498378003 0.969178199 #> [41] 0.567448748 -0.584465676 -0.569081556 0.480772528 0.540286912 #> [46] -0.925905068 0.513920167 0.163976300 -0.391761062 -0.676471023 #> [51] -0.150523719 0.807791932 -0.044178093 -0.209198969 -0.642383154 #> [56] 0.279816237 -0.155907350 -0.059505201 -0.109381977 -0.502682568 #> [61] -0.356437722 0.125351971 0.211673668 -0.211059997 -0.257598539 #> [66] 0.047509227 -0.275738223 -0.110972537 -0.183728282 0.314123494 #> [71] -0.443647377 0.160335079 -0.084228446 -0.535079859 -0.195346962 #> [76] -0.057451475 0.158969490 -0.302475088 0.579821667 -0.216988427 #> [81] -0.389228199 -0.643880452 -0.151623621 -0.204034908 0.035256290 #> [86] 0.390260787 1.185438234 -1.081983377 -0.025601498 -0.196204865 #> [91] -0.193417478 -0.295844292 0.390382634 -0.476297982 0.225940071 #> [96] -0.439571536 -0.437470518 -0.286314983 -0.771266013 -0.314513363 #> attr(,"scale_item_names") #> [1] "bfi_e1" "bfi_e2R" "bfi_e3" #> attr(,"label") #> [1] "aggregate of 3 bfi_e items"