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:
titanic.df <- read.csv(paste("TitanicData.csv"))
View(titanic.df)
Number of Passengers :
passengers <- titanic.df[,1]
length(passengers)
require(dplyr)
glimpse(titanic.df)
Number of Survivors :
survivors <-filter(titanic.df,Survived==1)
length(survivors[,1])
Percentage of Survivors :
prop.table(table(titanic.df$Survived))
Number of first class survivors :
firstsurvivors <-filter(survivors,Pclass==1)
length(firstsurvivors[,1])
Percentage of passengers in first class who survived :
firstclass <-filter(titanic.df,Pclass==1)
prop.table(table(firstclass$Survived))
Number of Females in First Class who survived :
femalesfirst <- filter(firstsurvivors,Sex=='female')
length(femalesfirst[,1])
Percentage of Survivors who were female :
prop.table(table(survivors$Sex))
Percentage of Females who survived :
females <-filter(titanic.df,Sex=='female')
prop.table(table(females$Survived))
Pearson Chi Square Test :
mytable <-xtabs(~Sex+Survived,data=titanic.df)
addmargins(mytable)
chisq.test(mytable)
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.