within_ci: Within Subjects Confidence Intervals.

Description Usage Arguments Value Examples

Description

within_ci returns lower and upper bounds of confidence intervals per factor for data with at least one within subject factor.

Usage

1
2
within_ci(data, subject, value, conf = 0.95, ws_factors = c(),
  bs_factors = c())

Arguments

data:

Dataframe in long format

subject:

Name of single column in data containing participant identifiers

value:

Name of single column in data containing values of DV

conf:

Confidence interval to be calculated

ws_factors:

names of (multiple) columns in data containing within-subject factors

bs_factors:

names of (multiple) columns in data containing between-subject factors

Value

Returns length of Confidence Intervals per factor

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
# One within factor, no between factors
within_ci(data = data_1w,
           subject = subject,
           value = DV,
           ws_factors = within1)

# Multiple within and between factors
within_ci(data = data_2w2b,
           subject = subject,
           value = DV,
           ws_factors = c(within1, within2),
           bs_factors = c(between1, between2))

# Multiple within and between factors with graph
 data_2w2b %>%
   within_ci(data = .,
             subject = subject,
             value = DV,
             ws_factors = c(within1, within2),
             bs_factors = c(between1, between2)) %>%
  ggplot(aes(x = within1,
             y = sample_mean,
             group = within2)) +
  geom_bar(stat = "identity",
           position = position_dodge(width = 1),
           color = "black",
           aes(fill = within2)) +
  geom_errorbar(position = position_dodge(width = 1),
                width = .1,
                aes(ymin = sample_mean - CI,
                    ymax = sample_mean + CI)) +
  scale_fill_manual(values = c("white", "grey")) +
  labs(y = "DV",
       title = "Example bar plot - two within two between") +
  theme_classic() +
  facet_grid(between1 ~ between2)

chrisharrisUU/goallabr documentation built on June 14, 2019, 12:03 a.m.