ar_cross_targets
creates tables counting targets among responses, for each combination of participant varable groups seperately.
Arguments
- associations
an
associatoR
object containing association data as generated by ar_import with targets defined by ar_set_targets.- participant_vars
a variable name vector specifying the participant varables to group counts with.
- target_var
a variable name specifying the targets variable group counts with.
- normalize
a
logical
scalar, indicating if counts should be normalized to the participant varable groups. Defaults toFALSE
.
Value
Returns a tibble containing grouped counts, or grouped counts normalized within participant variable groups if normalize = TRUE
.
Examples
# one participant variable, no normalization
ar_import(intelligence,
participant = participant_id,
cue = cue,
response = response,
participant_vars = c(gender, education),
response_vars = c(response_position, response_level)) %>%
ar_set_targets(targets = "cues") %>%
ar_embed_targets() %>%
ar_cluster_targets() %>%
ar_cross_targets(participant_vars = gender, target_var = cluster)
#> 456 targets with count < min_count were dropped from embedding.
#> # A tibble: 10 × 3
#> gender cluster n
#> <chr> <chr> <int>
#> 1 female cluster_1 1525
#> 2 female cluster_2 1127
#> 3 female cluster_3 1371
#> 4 female cluster_4 1100
#> 5 female no_cluster 1456
#> 6 male cluster_1 1163
#> 7 male cluster_2 1764
#> 8 male cluster_3 965
#> 9 male cluster_4 833
#> 10 male no_cluster 1331
# two participant variables, normalized
ar_import(intelligence,
participant = participant_id,
cue = cue,
response = response,
participant_vars = c(gender, education),
response_vars = c(response_position, response_level)) %>%
ar_set_targets(targets = "cues") %>%
ar_embed_targets() %>%
ar_cluster_targets() %>%
ar_cross_targets(participant_vars = c(gender, education), target_var = cluster, normalize = TRUE)
#> 456 targets with count < min_count were dropped from embedding.
#> # A tibble: 20 × 4
#> gender education cluster proportion
#> <chr> <chr> <chr> <dbl>
#> 1 female high school cluster_1 0.142
#> 2 female high school cluster_2 0.165
#> 3 female high school cluster_3 0.300
#> 4 female high school cluster_4 0.176
#> 5 female high school no_cluster 0.217
#> 6 female university cluster_1 0.130
#> 7 female university cluster_2 0.156
#> 8 female university cluster_3 0.225
#> 9 female university cluster_4 0.262
#> 10 female university no_cluster 0.226
#> 11 male high school cluster_1 0.137
#> 12 male high school cluster_2 0.275
#> 13 male high school cluster_3 0.242
#> 14 male high school cluster_4 0.118
#> 15 male high school no_cluster 0.228
#> 16 male university cluster_1 0.139
#> 17 male university cluster_2 0.298
#> 18 male university cluster_3 0.184
#> 19 male university cluster_4 0.169
#> 20 male university no_cluster 0.210