#+ message=FALSE
library(ggplot2)
library(Sleuth3)
library(openintro)
str(case0101)
head(case0101)
summary(case0101)
xbar <- mean(textbooks$diff) # x bar
s <- sd(textbooks$diff) # s
n <- length(textbooks$diff) # n
se_xbar <- s/sqrt(n)
df <- n - 1
xbar - qt(0.975, df) * se_xbar
xbar + qt(0.975, df) * se_xbar
#' With 95% confidence the price of a textbook is on average between $9.44 and $16.09 cheaper at Amazon than at the UCLA bookstore.
#' ### Optional part
lwr <- xbar - qt(0.975, df) * se_xbar
upr <- xbar + qt(0.975, df) * se_xbar
#' With 95% confidence the price of a textbook is on average between $`r round(lwr,2)` and $`r round(upr,2)` cheaper at Amazon than at the UCLA bookstore.
#' ### End Optional part
#+ fig.width=4, fig.height = 3
qplot(Treatment, Score, data = case0101)
qplot(Treatment, Score, data = case0101,
geom = "boxplot")
qplot(Treatment, Score, data = case0101,
geom = "violin")
qplot(Treatment, Score, data = case0101) +
geom_dotplot(binaxis = "y",
stackdir = "center")