Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please Use R studio and answer the following questions! R Code used to obtain th

ID: 3353905 • Letter: P

Question

Please Use R studio and answer the following questions! R Code used to obtain the answers should be provided!

R Data file : https://drive.google.com/file/d/18KcZeC2HyC4PPP6Jas3FY8ijs7Dsqccl/view?usp=sharing

In this problem, we will find numerical and graphical summaries of the Titanic dataset using R. The dataset consists of information on all the passengers of the ill-fated trans Atlantic ship Titanic. We are looking at only 3 columns (variables) in the dataset, namely Age, Sex and Survival status of the passengers. The dataset “titanic asRData" is (.RData is a convenient R data format) available in the homework folder on Carmen. Load the file using the command 1. load("titanic_as.RData") Note, if you are not in the same directly as the .RData file then you need to put the filepath in front of titanic_as.RData. Once you load the data you should see a data.frame object with the name "titanic_as". The data.frame has 3 columns/variables, Age, Sex and Survived. In the variable “Sex", 0 indicates female and 1 indicates male. In the variable "Survived", 0 indicates did not survive and 1 indicates survived. Note that the data does not contain information on all the passengers and may not match the version of the same dataset available elsewhere. Use only this dataset to answer the following questions. You should report all R code used to obtain the answers (at the end of your homework as a script). Do NOT print the data file a) b) What fraction of people survived the crash? Report the summary statistics for the variable Age. Your summary statistics should at least contain the mean, median and standard deviation Report the summary statistics for the variable Age only for those passengers who survived the crash (i.e., whose value in the Survived column is 1) Plot the histogram for the variable Sex. Then, plot the histogram for the same variable, but only for people who survived What comments can you make about the proportions of male-female passengers in the entire ship, and among those who survived, on the basis of the two histograms you generated in part (d)? c) d) e)

Explanation / Answer

Hi!

I'm pasting the entire R code for the problem. Simply Copy paste it in your Console and run one by one. The Conclusion is written in # as a comment in the code itself.

R-Code:

load("titanic_as.RData")
View(titanic_as)
attach(titanic_as)

##a##
table(Survived)
#Ans: 313 people survived out of 756
prop.table(table(Survived))
# 41.40% people survived
#______________________________________________________________

##b##
summary(Age)
#Mean = 30.40 and Median = 28
sd(Age)
#Standard Deviation = 14.25905
#______________________________________________________________

##c##
summary(Age[Survived==1])
#______________________________________________________________

##d##
hist(Sex,col = "blue")

hist(Sex[Survived==1],col = "red",main = "Histogram of Survived",xlab = "Sex")
#______________________________________________________________

'''
##e##
According to Histogram 1, we see the population of 1 (Male) is more than 0 (Female)
while according to the Histogram 2, we see the Females survived more than Males
'''

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote