plot_avg_diff: Plots average difference between looks to two interest areas.

Description Usage Arguments Examples

View source: R/plotting.R

Description

plot_avg_diff calculates the grand or conditional averages of differences between looks to two interest area along with standard error. It then plots the results.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
plot_avg_diff(
  data,
  DiffCols = NULL,
  xlim = NA,
  type = NULL,
  Averaging = "Event",
  Condition1 = NULL,
  Condition2 = NULL,
  Cond1Labels = NA,
  Cond2Labels = NA,
  ErrorBar = TRUE,
  VWPreTheme = TRUE,
  ConfLev = 95,
  CItype = "simultaneous",
  ErrorBand = FALSE,
  ErrorType = "SE"
)

Arguments

data

A data table object output by either bin_prop. transform_to_elogit, or create_binomial.

DiffCols

A named character vector specifying the desired columns corresponding to the interest areas.

xlim

A vector of two integers specifying the limits of the x-axis.

type

A character string indicating "proportion" or "elogit" which influences how standard error and confidence intervals are calculated.

Averaging

A character string indicating how the averaging should be done. "Event" (default) will produce the overall mean in the data, while "Subject" or "Item" (or, in principle, any other column name) will calculate the grand mean by that factor.

Condition1

A string containing the column name corresponding to the first condition, if available.

Condition2

A string containing the column name corresponding to the second condition, if available.

Cond1Labels

A named character vector specifying the desired labels of the levels of the first condition.

Cond2Labels

A named character vector specifying the desired labels of the levels of the second condition.

ErrorBar

A logical indicating whether error bars should be included in the plot.

VWPreTheme

A logical indicating whether the theme included with the function should be applied, or ggplot2's base theme (to which any other custom theme could be added).

ConfLev

A number indicating the confidence level of the CI.

CItype

A string indicating "simultaneous" or "pointwise". Simultaneous performs a Bonferroni correction for the interval.

ErrorBand

A logical indicating whether error bands should be included in the plot.

ErrorType

A string indicating "SE" or "CI".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 
library(VWPre)
# For plotting average differences with SE bars...
plot_avg_diff(data = dat, xlim = c(0, 1000), type = "proportion",
             DiffCols = c(IA_1_P = "Target", IA_2_P = "Rhyme"),
             Condition1 = NA, Condition2 = NA, Cond1Labels = NA, Cond2Labels = NA,
             ErrorBar = TRUE, VWPreTheme = TRUE, ErrorBand = FALSE, 
             ErrorType = "SE")
             
# For plotting conditional average differences (one condition) with the 
# included theme and 95% pointwise CI bars.
plot_avg_diff(data = dat, xlim = c(0, 1000), , type = "proportion",
             DiffCols = c(IA_1_P = "Target", IA_2_P = "Rhyme"),
           Condition1 = "talker", Condition2 = NA, Cond1Labels = c(CH1 = "Chinese 1", 
           CH10 = "Chinese 3", CH9 = "Chinese 2", EN3 = "English 1"),
           Cond2Labels = NA, ErrorBar = TRUE, 
           VWPreTheme = TRUE, ErrorBand = FALSE, 
             ErrorType = "CI", ConfLev = 95, CItype = "pointwise")
           
# For plotting conditional average differences (two conditions) with the 
# included theme and 95% simultaneous CI bands.
plot_avg_diff(data = dat, xlim = c(0, 1000), , type = "proportion",
             DiffCols = c(IA_1_P = "Target", IA_2_P = "Rhyme"),
           Condition1 = "talker", Condition2 = "Exp", Cond1Labels = c(CH1 = "Chinese 1", 
           CH10 = "Chinese 3", CH9 = "Chinese 2", EN3 = "English 1"),
           Cond2Labels = c(High = "H Exp", Low = "L Exp"), ErrorBar = FALSE, 
           VWPreTheme = TRUE, ErrorBand = TRUE, 
             ErrorType = "CI", ConfLev = 95, CItype = "simultaneous")

# For a more complete tutorial on VWPre plotting functions:
vignette("SR_Plotting", package="VWPre")

## End(Not run)

VWPre documentation built on Nov. 30, 2020, 1:08 a.m.