library(readxl)
Titanic<- read_excel("C:/Users/j.k/Desktop/New folder/Titanic.xls")
View(Titanic)
survive <- Titanic[ which(Titanic$Survived== 1 & Titanic$Age< 100), ]
died <- Titanic[ which(Titanic$Survived== 0 & Titanic$Age< 100), ]
mean(survive$Age)
## [1] 28.42382
mean((died$Age))
## [1] 30.4153
x<- survive$Age
y<- died$Age
mu1<-mean(survive$Age)
mu2<-mean((died$Age))
t.test(x, y=NULL, alternative = c("two.sided", "less", "greater"), mu1 < mu2, paired = FALSE, var.equal = FALSE, conf.level = 0.95 )
## 
##  One Sample t-test
## 
## data:  x
## t = 36.957, df = 339, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to TRUE
## 95 percent confidence interval:
##  26.96422 29.88342
## sample estimates:
## mean of x 
##  28.42382
t.test(x,y)
## 
##  Welch Two Sample t-test
## 
## data:  x and y
## 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:
##  -3.7838912 -0.1990628
## sample estimates:
## mean of x mean of y 
##  28.42382  30.41530