Skip to contents

ar_cross_targets creates tables counting targets among responses, for each combination of participant varable groups seperately.

Usage

ar_cross_targets(associations, participant_vars, target_var, normalize = FALSE)

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 to FALSE.

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    856
#>  2 female cluster_2   1306
#>  3 female cluster_3   1638
#>  4 female cluster_4   1323
#>  5 female no_cluster  1456
#>  6 male   cluster_1    814
#>  7 male   cluster_2   1877
#>  8 male   cluster_3   1189
#>  9 male   cluster_4    845
#> 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.113 
#>  2 female high school cluster_2      0.189 
#>  3 female high school cluster_3      0.295 
#>  4 female high school cluster_4      0.187 
#>  5 female high school no_cluster     0.217 
#>  6 female university  cluster_1      0.0900
#>  7 female university  cluster_2      0.187 
#>  8 female university  cluster_3      0.200 
#>  9 female university  cluster_4      0.297 
#> 10 female university  no_cluster     0.226 
#> 11 male   high school cluster_1      0.103 
#> 12 male   high school cluster_2      0.288 
#> 13 male   high school cluster_3      0.234 
#> 14 male   high school cluster_4      0.147 
#> 15 male   high school no_cluster     0.228 
#> 16 male   university  cluster_1      0.0918
#> 17 male   university  cluster_2      0.321 
#> 18 male   university  cluster_3      0.166 
#> 19 male   university  cluster_4      0.211 
#> 20 male   university  no_cluster     0.210