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   1296
#>  2 female cluster_2   1176
#>  3 female cluster_3   1716
#>  4 female cluster_4    935
#>  5 female no_cluster  1456
#>  6 male   cluster_1   1044
#>  7 male   cluster_2   1793
#>  8 male   cluster_3   1288
#>  9 male   cluster_4    600
#> 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.222 
#>  2 female high school cluster_2      0.175 
#>  3 female high school cluster_3      0.298 
#>  4 female high school cluster_4      0.0885
#>  5 female high school no_cluster     0.217 
#>  6 female university  cluster_1      0.244 
#>  7 female university  cluster_2      0.181 
#>  8 female university  cluster_3      0.208 
#>  9 female university  cluster_4      0.140 
#> 10 female university  no_cluster     0.226 
#> 11 male   high school cluster_1      0.195 
#> 12 male   high school cluster_2      0.282 
#> 13 male   high school cluster_3      0.242 
#> 14 male   high school cluster_4      0.0526
#> 15 male   high school no_cluster     0.228 
#> 16 male   university  cluster_1      0.192 
#> 17 male   university  cluster_2      0.314 
#> 18 male   university  cluster_3      0.168 
#> 19 male   university  cluster_4      0.116 
#> 20 male   university  no_cluster     0.210