plot_avg: Plots average looks to interest areas.

Description Usage Arguments Examples

View source: R/plotting.R

Description

plot_avg calculates the grand or conditional averages of looks to each interest area along with standard error. It then plots the results. N.B.: This function will work for data with a maximum of 8 interest areas and 2 conditions.

Usage

1
2
3
4
5
plot_avg(data, type = NULL, xlim = NA, IAColumns = 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.

type

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

xlim

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

IAColumns

A named character vector specifying the desired interest area columns with custom strings for the legend.

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 custom labels of the levels of the first condition.

Cond2Labels

A named character vector specifying the desired custom 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". For SE, the calculation varies for empirical logits and proportions. Further, for CI, the calculation on proportions uses the Wald method.

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
34
35
36
37
38
## Not run: 
library(VWPre)
# For plotting the grand average with the included theme and SE bars
plot_avg(data = dat, type = "elogit", xlim = c(0, 1000), 
   IAColumns = c(IA_1_ELogit = "Target", IA_2_ELogit = "Rhyme", 
   IA_3_ELogit = "OnsetComp", IA_4_ELogit = "Distractor"), 
   Averaging = "Event", Condition1 = NA, Condition2 = NA, 
   Cond1Labels = NA, Cond2Labels = NA,
   ErrorBar = TRUE, VWPreTheme = TRUE, ErrorType = "SE",
   ErrorBand = FALSE) 
   
# For plotting conditional averages (one condition) with the included theme
# and 95% simultaneous CI bars.
# This produces plots arranged horizontally
plot_avg(data = dat, type = "elogit", xlim = c(0, 1000), 
   IAColumns = c(IA_1_ELogit = "Target", IA_2_ELogit = "Rhyme", 
   IA_3_ELogit = "OnsetComp", IA_4_ELogit = "Distractor"),
   Averaging = "Event", Condition1 = NA, Condition2 = "talker", 
   Cond1Labels = NA, 
   Cond2Labels = c(CH1 = "Chinese 1", CH10 = "Chinese 3", CH9 = "Chinese 2", 
   EN3 = "English 1"), ErrorBar = TRUE, VWPreTheme = TRUE,
   ErrorBands = FALSE, ErrorType = "CI", ConfLev = 95, CItype = "simultaneous")

# For plotting conditional averages (two conditions) for one interest area
with the included theme and 95% simultaneous CI bands.
# This produces plots arranged in grid format.
plot_avg(data = dat, type = "elogit", xlim = c(0, 1000),
   IAColumns = c(IA_1_ELogit = "Target"), Averaging = "Event", 
   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, ErrorBands = 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 Dec. 5, 2017, 9:03 a.m.