Create a list of possible pairwise comparisons between groups. If a reference group is specified, only comparisons against reference will be kept.

get_comparisons(data, variable, ref.group = NULL)

Arguments

data

a data frame

variable

the grouping variable name. Can be unquoted.

ref.group

a character string specifying the reference group. Can be unquoted. If numeric, then it should be quoted. If specified, for a given grouping variable, each of the group levels will be compared to the reference group (i.e. control group).

If ref.group = "all", pairwise comparisons are performed between each grouping variable levels against all (i.e. basemean).

Value

a list of all possible pairwise comparisons.

Examples

# All possible pairwise comparisons
ToothGrowth %>%
  get_comparisons("dose")
#> $V1
#> [1] "0.5" "1"  
#> 
#> $V2
#> [1] "0.5" "2"  
#> 
#> $V3
#> [1] "1" "2"
#> 

# Comparisons against reference groups
ToothGrowth %>%
  get_comparisons("dose", ref.group = "0.5")
#> $V1
#> [1] "0.5" "1"  
#> 
#> $V2
#> [1] "0.5" "2"  
#> 

# Comparisons against  all (basemean)
ToothGrowth %>%
  get_comparisons("dose", ref.group = "all")
#> $V1
#> [1] "all" "0.5"
#> 
#> $V2
#> [1] "all" "1"  
#> 
#> $V3
#> [1] "all" "2"  
#>