So, you’ve appropriately applied the one-way ANOVA methodology within the R-Programming Language – and you’ve already reported your results within the APA format. However, you now require a visualization of your data.
Example:
In order for this code to function, your data must be structured in a manner which resembles the following graphic:
All of the factors must be contained within a single variable (Group), and all of the associated observations must be contained with a corresponding variable (Observation).
The following code below will create the example’s data frame within the R-Programming Language.
Group = c('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D')
Observation = c(3, 6, 6, 2, 4, 6, 5, 4, 7, 7, 6, 2, 2, 4, 7, 7, 6, 6, 7, 7, 7, 7, 7, 6, 6, 7, 7, 5, 2, 5, 4, 4, 7, 4, 4, 5, 5, 6, 7, 6, 1, 1, 6, 1, 5, 7, 7, 7, 4, 6, 4, 2, 3, 7, 7, 7, 5, 7, 7, 7, 7, 7, 6, 7, 6, 7, 7, 7, 7, 7, 4, 6, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1)
ANOVA_TEST = data.frame(Group, Observation)
###########################################################################
# Getting the Libraries in Order (for Graphical Output) #
library(ggplot2)
library(gplots)
## Requires library 'ggplot2' ##
ggplot(ANOVA_TEST) +
aes(x = Group, y = Observation, color = Group, shape = Group) + ## Each group has its own color and each group has its own shape. Remove "shape = " to surpress this ##
geom_jitter(width = 0.2, alpha = 0.6) + ## Tighten up the group width ##
stat_summary(fun = mean, geom = "point", shape = 95, size = 6) + # color mapped by Group ##
## The "-" found in each group's y-axis values, is the mean value for that group ##
theme(legend.position = "right") ## To remove the legend, select legend.position = "none" ##
## Requires library 'gplots' ##
ANOVA_TEST$Group = factor(ANOVA_TEST$Group)
plotmeans(ANOVA_TEST$Observation ~ ANOVA_TEST$Group,
xlab = "Watch Type\n(Error Bars: 95% CI)", # x-axis label
ylab = "Observation",
main = "Place Your Title Here",
pch = 16) # Solid points #
theme(legend.position = "right") ## To remove the legend, select legend.position = "none" ##
## Requires library 'gplots' ##
ANOVA_TEST$Group = factor(ANOVA_TEST$Group)
plotmeans(ANOVA_TEST$Observation ~ ANOVA_TEST$Group,
xlab = "Watch Type\n(Error Bars: 95% CI)", # x-axis label
ylab = "Observation",
main = "Place Your Title Here",
pch = 16) # Solid points #
###########################################################################
In the above graphic, each group variable (factor) displayed on the x-axis, has its corresponding observational values displayed on the y-axis. Each group’s observations possess a different color and shape. The single dash “-“ found within each group amongst its observation points, represents that group’s mean value.
This graphic presents a different visualization approach. Each group on the x-axis has its number of corresponding observations displayed above each axis point (n=). The solid black dots represent the mean of each group on the x-axis, while the blue lines represent the range of associated confidence interval values.
These visualizations, along with your results reported within the APA format, should assist you in presenting your findings to readers in the most comprehensive manner possible. There are different customization options as it pertains to each graphing function. However, you’ll need to do additional research to determine what best works for your needs.
Until next time,
-RD