apa.ezANOVA.table: Creates an ANOVA table in APA style based output of ezANOVA...

Description Usage Arguments Value Examples

View source: R/apaEZANOVA.R

Description

Creates an ANOVA table in APA style based output of ezANOVA command from ez package

Usage

1
2
apa.ezANOVA.table(ez.output, correction = "GG", table.title = "", filename,
  table.number = NA)

Arguments

ez.output

Output object from ezANOVA command from ez package

correction

Type of sphercity correction: "none", "GG", or "HF" corresponding to none, Greenhouse-Geisser and Huynh-Feldt, respectively.

table.title

String containing text for table title

filename

(optional) Output filename document filename (must end in .rtf or .doc only)

table.number

Integer to use in table number output line

Value

APA table object

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
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#
# ** Example 1: Between Participant Predictors
#

library(apaTables)
library(ez)

# See format where one row represents one PERSON
# Note that participant, gender, and alcohol are factors

print(goggles)


# Use ezANOVA
# Be sure use the options command, as below, to ensure sufficient digits

options(digits = 10)
goggles_results <- ezANOVA(data = goggles,
                          dv = attractiveness,
                          between = .(gender, alcohol),
                          participant ,
                          detailed = TRUE)


# Make APA table

goggles_table <- apa.ezANOVA.table(goggles_results,
                                  filename="ex1_ez_independent.doc")

print(goggles_table)



#
# ** Example 2: Within Participant Predictors
#

library(apaTables)
library(tidyr)
library(forcats)
library(ez)

# See initial wide format where one row represents one PERSON
print(drink_attitude_wide)

# Convert data from wide format to long format where one row represents one OBSERVATION.
# Wide format column names MUST represent levels of each variable separated by an underscore.
# See vignette for further details.

drink_attitude_long <- gather(data = drink_attitude_wide,
                              key = cell, value = attitude,
                              beer_positive:water_neutral,
                              factor_key=TRUE)

drink_attitude_long <- separate(data = drink_attitude_long,
                                col = cell, into = c("drink","imagery"),
                                sep = "_", remove = TRUE)

drink_attitude_long$drink <- as_factor(drink_attitude_long$drink)
drink_attitude_long$imagery <- as_factor(drink_attitude_long$imagery)

# See new long format of data, where one row is one OBSERVATION.
# As well, notice that we have two columns (drink, imagery)
# drink, imagery, and participant are factors
print(drink_attitude_long)


# Set contrasts to match Field et al. (2012) textbook output

alcohol_vs_water <- c(1, 1, -2)
beer_vs_wine <- c(-1, 1, 0)
negative_vs_other <- c(1, -2, 1)
positive_vs_neutral <- c(-1, 0, 1)
contrasts(drink_attitude_long$drink) <- cbind(alcohol_vs_water, beer_vs_wine)
contrasts(drink_attitude_long$imagery) <- cbind(negative_vs_other, positive_vs_neutral)


# Use ezANOVA
# Be sure use the options command, as below, to ensure sufficient digits

options(digits = 10)
drink_attitude_results <- ezANOVA(data = drink_attitude_long,
                   dv = .(attitude), wid = .(participant),
                   within = .(drink, imagery),
                   type = 3, detailed = TRUE)


# Make APA table

drink_table <- apa.ezANOVA.table(drink_attitude_results,
                                 filename="ex2_repeated_table.doc")

print(drink_table)


#
# ** Example 3: Between and Within Participant Predictors
#

library(apaTables)
library(tidyr)
library(forcats)
library(ez)

# See initial wide format where one row represents one PERSON
print(dating_wide)


# Convert data from wide format to long format where one row represents one OBSERVATION.
# Wide format column names MUST represent levels of each variable separated by an underscore.
# See vignette for further details.

dating_long <- gather(data = dating_wide,
                     key = cell, value = date_rating,
                     attractive_high:ugly_none,
                     factor_key = TRUE)

dating_long <- separate(data = dating_long,
                       col = cell, into = c("looks","personality"),
                       sep = "_", remove = TRUE)

dating_long$looks <- as_factor(dating_long$looks)
dating_long$personality <- as_factor(dating_long$personality)


# See new long format of data, where one row is one OBSERVATION.
# As well, notice that we have two columns (looks, personality)
# looks, personality, and participant are factors

print(dating_long)

# Set contrasts to match Field et al. (2012) textbook output

some_vs_none <- c(1, 1, -2)
hi_vs_av <- c(1, -1, 0)
attractive_vs_ugly <- c(1, 1, -2)
attractive_vs_average <- c(1, -1, 0)
contrasts(dating_long$personality) <- cbind(some_vs_none, hi_vs_av)
contrasts(dating_long$looks) <- cbind(attractive_vs_ugly, attractive_vs_average)


# Use ezANOVA

library(ez)
options(digits = 10)
dating_results <-ezANOVA(data = dating_long, dv = .(date_rating), wid = .(participant),
                        between = .(gender), within = .(looks, personality),
                        type = 3, detailed = TRUE)


# Make APA table

dating_table <- apa.ezANOVA.table(dating_results,
                                 filename = "ex3_mixed_table.doc")
print(dating_table)

dstanley4/apaTables documentation built on July 16, 2018, 4:08 p.m.