This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
TASK 4a TASK 4b
titanic.df <- read.csv(paste("Titanic Data.csv", sep=""))
titanic.df$Survived=factor(titanic.df$Survived, levels = c(0,1), labels = c("Not survived","Survived"))
aggregate(titanic.df$Age, by=list(titanic.df$Survived),mean)
## Group.1 x
## 1 Not survived 30.41530
## 2 Survived 28.42382
TASK 4c
t.test(titanic.df$Age~titanic.df$Survived, var.equal=TRUE)
##
## Two Sample t-test
##
## data: titanic.df$Age by titanic.df$Survived
## t = 2.2302, df = 887, p-value = 0.02599
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.238890 3.744064
## sample estimates:
## mean in group Not survived mean in group Survived
## 30.41530 28.42382
Since the P vavlue is higher than 0.05, the hypotheises is true.