library(readr)
library(AER)
Titanic_2 <- read_csv("https://stanford.io/2O9RUCF")[,-3]
colnames(Titanic_2) = c("Survived", "Class", "Sex", "Age", "Siblings", "Parents", "Fare")
# generate `t_abs`, a contingency table of `Survived` and `Class`
# generate `t_rel`, the table of the relative frequencies
# create the barplot
# generate `t_abs`, a contingency table of `Survived` and `Class`
t_abs <-table(Titanic_2$Survived, Titanic_2$Class)
# generate `t_rel`, the table of the relative frequencies
t_rel <- t_abs/nrow(Titanic_2)
# create the barplot
barplot(table(Titanic_2$Survived, Titanic_2$Class)/nrow(Titanic_2),
col = c("darkred","darkgreen"),
ylim = c(0,0.6),
main = "Relative Frequencies of Survival",
xlab = "Class")
test_predefined_objects("Titanic_2")
test_object("t_abs")
test_object("t_rel")
test_function("barplot", args = "height")