This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. Review this website for more details on using R Markdown http://rmarkdown.rstudio.com.
Use RStudio for this assignment. Complete the assignment by inserting your R code wherever you see the string “#INSERT YOUR ANSWER HERE”.
When you click the Knit button, a document (PDF, Word, or HTML format) will be generated that includes both the assignment content as well as the output of any embedded R code chunks.
Submit both the rmd and generated output files. Failing to submit both files will be subject to mark deduction.
Use seq() to create the vector [3,5, … ,29).
seq(3, 30, 2)
## [1] 3 5 7 9 11 13 15 17 19 21 23 25 27 29
seq(3, 29, 2)
## [1] 3 5 7 9 11 13 15 17 19 21 23 25 27 29
The Titanic Passenger Survival Data Set provides information on the fate of passengers on the fatal maiden voyage of the ocean liner “Titanic.” The dataset is available from the Department of Biostatistics at the Vanderbilt University School of Medicine (https://biostat.app.vumc.org/wiki/pub/Main/DataSets/titanic3.csv)in several formats. store the Titanic Data Set titanic_train using the following commands.
#install.packages("titanic")
library(titanic)
titanicDataset <- read.csv(file = "https://biostat.app.vumc.org/wiki/pub/Main/DataSets/titanic3.csv", stringsAsFactors = F)
summary(titanicDataset)
## pclass survived name sex
## Min. :1.000 Min. :0.000 Length:1309 Length:1309
## 1st Qu.:2.000 1st Qu.:0.000 Class :character Class :character
## Median :3.000 Median :0.000 Mode :character Mode :character
## Mean :2.295 Mean :0.382
## 3rd Qu.:3.000 3rd Qu.:1.000
## Max. :3.000 Max. :1.000
##
## age sibsp parch ticket
## Min. : 0.17 Min. :0.0000 Min. :0.000 Length:1309
## 1st Qu.:21.00 1st Qu.:0.0000 1st Qu.:0.000 Class :character
## Median :28.00 Median :0.0000 Median :0.000 Mode :character
## Mean :29.88 Mean :0.4989 Mean :0.385
## 3rd Qu.:39.00 3rd Qu.:1.0000 3rd Qu.:0.000
## Max. :80.00 Max. :8.0000 Max. :9.000
## NA's :263
## fare cabin embarked boat
## Min. : 0.000 Length:1309 Length:1309 Length:1309
## 1st Qu.: 7.896 Class :character Class :character Class :character
## Median : 14.454 Mode :character Mode :character Mode :character
## Mean : 33.295
## 3rd Qu.: 31.275
## Max. :512.329
## NA's :1
## body home.dest
## Min. : 1.0 Length:1309
## 1st Qu.: 72.0 Class :character
## Median :155.0 Mode :character
## Mean :160.8
## 3rd Qu.:256.0
## Max. :328.0
## NA's :1188
# if you get the following error message when you knit
# Error in contrib.url(repos,"source")
# you can fix it in 2 ways
# Method 1: comment out the install.packages() in your code
# Method 2: add specific repos address in the install.package() comments, e.g. install.packages("package_name", repos = "http://cran.us.r-project.org")
sex, age, fare, cabin and survived into a new data frame of the name ‘titanicSubset’. (5 points)#INSERT YOUR ANSWER HERE
dplyr package to display the total number of passengers within each Ticket Class Pclass. (5 points) HINT: use %>% to pipe the dataframe to count().#INSERT YOUR ANSWER HERE
dplyr package to calculate the number of passengers by sex. (5 points) HINT: use group_by() first then pipe the result to count() to calculate the number of passengers per#INSERT YOUR ANSWER HERE
sex and calculate the survival rate of each sex. Then draw the conclusion on which sex has the higher survival rate. (5 points)#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
In a shipment of 20 engines, history shows that the probability of any one engine proving unsatisfactory is 0.1
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
On average, John goes to his parents’ place twice a week for visits.
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
Write a script in R to compute the following probabilities of a normal random variable with mean 16 and variance 9
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
#INSERT YOUR ANSWER HERE
END of Assignment #2.