This is an R Markdown document which shows the results of a t-test performed on the dataset Titanic. This also displays the calculations performed on the dataset to calculate the average age of survivors and the passengers who died in Titanic.
setwd("F:/R-Internship/Course related files")
Titanic1.df<-read.csv(paste("Titanic Data.csv",sep=""))
View(Titanic1.df)
Titanic1.df$Survived=factor(Titanic1.df$Survived,levels=c(0,1),labels=c("People died","Survived"))
aggregate(Titanic1.df$Age,by=list(Titanic1.df$Survived),FUN=mean)
## Group.1 x
## 1 People died 30.41530
## 2 Survived 28.42382
t.test(Age~Survived,data=Titanic1.df)
##
## Welch Two Sample t-test
##
## data: Age by Survived
## t = 2.1816, df = 667.56, p-value = 0.02949
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.1990628 3.7838912
## sample estimates:
## mean in group People died mean in group Survived
## 30.41530 28.42382