Modelled on haven::zap_labels()
, but more encompassing. By default removes
the following attributes:
format.spss, format.sas, format.stata, label, labels, na_values, na_range,
display_width
Modelled on haven::zap_labels()
, but more encompassing. By default removes
the following attributes:
format.spss, format.sas, format.stata, label, labels, na_values, na_range,
display_width
Examples
bfi <- data.frame(matrix(data = rnorm(300), ncol = 3))
names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3")
attributes(bfi$bfi_e1)$label <- "I am outgoing."
attributes(bfi$bfi_e2R)$label <- "I prefer books to people."
attributes(bfi$bfi_e3)$label <- "I love to party."
bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")])
bfi <- detect_scales(bfi, quiet = TRUE) # create attributes
str(zap_attributes(bfi, "label"))
#> 'data.frame': 100 obs. of 4 variables:
#> $ bfi_e1 : num 0.2154 0.1924 -0.0188 1.0782 1.7582 ...
#> $ bfi_e2R: num -0.5637 -1.4025 -2.3491 0.0793 1.2248 ...
#> $ bfi_e3 : num 0.449 -0.258 -0.717 -0.225 0.26 ...
#> $ bfi_e : num 0.0335 -0.4892 -1.0282 0.3108 1.081 ...
#> ..- attr(*, "scale_item_names")= chr [1:3] "bfi_e1" "bfi_e2R" "bfi_e3"
zap_attributes(bfi$bfi_e)
#> [1] 0.033521830 -0.489214026 -1.028169437 0.310835809 1.080984008
#> [6] 0.186740025 -0.004104253 1.019459431 -1.151478960 -0.009786653
#> [11] 0.198577688 0.684540653 -0.081271361 -0.006924049 -0.270495940
#> [16] -0.127314812 -0.450675910 -0.255239133 0.111597528 -0.351254628
#> [21] -0.477726076 -0.585710943 -0.727025190 -0.096506554 -0.305682265
#> [26] -0.561809361 0.857179159 0.194983468 -0.067084362 0.130067596
#> [31] -0.213378743 -0.091963570 0.561315920 -0.111306149 -0.361031207
#> [36] -0.242367684 1.274835781 -0.127851633 -0.263910556 -0.274003693
#> [41] -0.927901284 1.017808455 -0.886265267 -0.162162492 0.587376565
#> [46] -0.754100468 0.566094969 -0.220948596 1.028583311 -0.582840080
#> [51] 0.165262071 0.228629128 -0.629373066 -0.832428417 -0.235853871
#> [56] 0.606029106 0.804578053 -0.193818382 0.065907277 -0.457479365
#> [61] -0.138117281 0.989167581 0.133539814 0.155028258 0.409615917
#> [66] -0.162410026 0.574497417 0.164201118 -0.887644905 0.541568698
#> [71] 0.492000032 -0.155672293 0.594756415 1.154984921 1.832769460
#> [76] -0.518284857 -1.357618880 0.659036881 0.218730756 0.292376303
#> [81] 0.863148324 0.345660349 -0.249865799 0.327621845 -0.591421719
#> [86] 0.276967302 0.576863456 0.789108084 -0.302243166 0.194340764
#> [91] 0.212521642 -0.581899587 -0.058666692 1.178802069 0.885454676
#> [96] 0.297452459 -0.760231667 0.514904431 -0.254481278 0.145778019
bfi <- data.frame(matrix(data = rnorm(300), ncol = 3))
names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3")
attributes(bfi$bfi_e1)$label <- "I am outgoing."
attributes(bfi$bfi_e2R)$label <- "I prefer books to people."
attributes(bfi$bfi_e3)$label <- "I love to party."
bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")])
bfi <- detect_scales(bfi, quiet = TRUE) # create attributes
str(zap_attributes(bfi, "label"))
#> 'data.frame': 100 obs. of 4 variables:
#> $ bfi_e1 : num 0.0773 -1.0804 1.1329 1.047 0.9049 ...
#> $ bfi_e2R: num -1.4102 -0.0123 0.7944 0.3618 1.5585 ...
#> $ bfi_e3 : num -0.381 -0.637 -1.465 -0.944 -1.519 ...
#> $ bfi_e : num -0.571 -0.576 0.154 0.155 0.315 ...
#> ..- attr(*, "scale_item_names")= chr [1:3] "bfi_e1" "bfi_e2R" "bfi_e3"
zap_attributes(bfi$bfi_e)
#> [1] -0.57130165 -0.57648396 0.15398894 0.15487921 0.31476927 0.77710333
#> [7] -0.51772833 -0.08662215 0.10998877 0.07820579 0.41982495 0.51196808
#> [13] 0.01339699 -0.45671314 0.69847360 -0.73378599 -1.03688472 0.21361582
#> [19] 0.04126257 0.49223886 -0.46067356 0.61906165 0.73262951 -0.21164239
#> [25] -0.75676898 0.91920009 0.27443198 -0.02042341 0.10980058 -0.75121945
#> [31] 0.54658096 0.23548549 0.66664103 0.44861597 1.01109739 0.63343394
#> [37] -1.23515016 0.36209288 -0.33516627 0.24801681 1.19470958 0.50257123
#> [43] -0.41947774 -0.02503102 0.16204421 -0.11097418 0.25277643 -0.75868150
#> [49] -1.27915782 -0.05982189 0.88571981 0.77558347 0.52929829 0.39176595
#> [55] -0.62558657 0.74272472 0.23602041 0.48666970 -1.54324056 0.33296381
#> [61] 0.83812541 -1.09021140 -0.22464109 -0.20917445 0.35482595 -0.12574700
#> [67] -0.10971118 0.25483071 -0.57916056 0.53905494 -0.13410289 -0.07406088
#> [73] 0.21712877 0.17208567 0.01295638 1.59417568 -0.78847861 0.17797955
#> [79] 0.87017085 -0.33034736 -0.53173808 0.07450761 -0.05375663 0.47715852
#> [85] 1.67225827 -0.86710195 -0.16050488 -0.40387020 -0.47791920 -0.91231069
#> [91] 0.31339042 -1.35665593 -0.26473937 -0.40075686 0.38347550 0.37477234
#> [97] -0.51348495 -1.66363840 -0.20473251 0.20372999