yawning

references:
- ISI, exploration 5.2, p.276

library(tidyverse)
library(knitr)

data

yawning1 <- read.csv("Yawning.csv", header = TRUE)
str(yawning1)
## 'data.frame':    50 obs. of  2 variables:
##  $ YawnSeed: Factor w/ 2 levels "Control","Seeded": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Response: Factor w/ 2 levels "NoYawn","Yawn": 2 2 2 2 2 2 2 2 2 2 ...
tbl <- yawning1 %>%
  group_by(YawnSeed, Response) %>%
  summarize(n = n())
tbl
## # A tibble: 4 x 3
## # Groups:   YawnSeed [?]
##   YawnSeed Response     n
##     <fctr>   <fctr> <int>
## 1  Control   NoYawn    13
## 2  Control     Yawn     3
## 3   Seeded   NoYawn    23
## 4   Seeded     Yawn    11

segmented barplot

ggplot(tbl, aes(x = YawnSeed, Response, y = n, fill = Response)) +
  geom_bar(stat = "identity", position = "fill") +
  scale_fill_manual(values = c("aquamarine", "burlywood")) +
  labs(title = "Yawning")