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
setwd("F:/!!!rd trimester/Data Analytics/day 5")
data.df<- read.csv(paste("Titanic Data.csv", sep = ""))
View(data.df)
Task 4b
aggregate(data.df$Age, by=list(sex=data.df$Sex, Survived=data.df$Survived==1), mean)
## sex Survived x
## 1 female FALSE 26.02346
## 2 male FALSE 31.17543
## 3 female TRUE 28.79784
## 4 male TRUE 27.63119
Task 4c
t.test(data.df$Survived, data.df$Age, paired=TRUE)
##
## Paired t-test
##
## data: data.df$Survived and data.df$Age
## t = -67.065, df = 888, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -30.12782 -28.41458
## sample estimates:
## mean of the differences
## -29.2712
Based on the output of Dependent T-Test, we can accept the Hypothesis, H2:The Titanic survivors were younger than the passengers who died.