Skip to contents

ar_compare_targets compares target characteristics between participant groups taking into account target frequencies in responses to return summary statistics.

Usage

ar_compare_targets(associations, participant_vars, target_var, fun = mean, ...)

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 grouping variables.

target_var

a variable name specifying the target variable to be summarized.

fun

a function specifying the statistic to calculate from target_var, defaults to mean.

...

additional arguments passed on to fun

Value

Returns a tibble containing grouped summaries based on fun.

Examples

# calculate means by using fun = mean and passing na.rm argument to mean()
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_summarize_targets(response_var = response_position) %>%
  ar_compare_targets(participant_vars = c(gender, education), target_var = response_position, fun = mean, na.rm = TRUE)
#> # A tibble: 4 × 3
#>   gender education   response_position
#>   <chr>  <chr>                   <dbl>
#> 1 female high school              2.88
#> 2 female university               2.98
#> 3 male   high school              2.90
#> 4 male   university               2.97