This is an RMarkdown file. Notice that it has different sections. Some are for code and they are called “code chunks.” These are are marked off with tickmarks and {r} which indicates that the code you are creating is in the R language.

On line 4, add your name (between the quotation marks) as the author of this document.

In this class we always need to start by loading the lehmansociology package which contains our data, templates and other useful things.

We will be using the ships data set.
Let’s look at the first line of the data set using the head() function.

head(ships, 1)
##   Ship Id Year Nationality of the Ship Women and children first Quick
## 1       1 1852                     U.K                        1     1
##       Cause No. of passengers No. of women passengers
## 1 Grounding               490                       7
##   Women passengers/passengers Length of voyage   Name of Ship Survived
## 1                       0.014               21 HMS Birkenhead        0
##   prop_survival Ship size
## 1     0.3435252       554

What is the Name of Ship and Ship Id for the first line?

ship id 1 ship name HMS Birkenhead

Now let’s get the list of all of the Ship Id and Ship Name values.

ships[c("Ship Id", "Name of Ship")]
##    Ship Id             Name of Ship
## 1        1           HMS Birkenhead
## 2        2                SS Arctic
## 3        3           SS Golden Gate
## 4        4            SS Northfleet
## 5        5             RMS Atlantic
## 6        6        SS Princess Alice
## 7        7                 SS Norge
## 8        8              RMS Titanic
## 9        9   RMS Empress of Ireland
## 10      10            RMS Lusitania
## 11      11   SS Principessa Mafalda
## 12      12               SS Vestris
## 13      13          SS Morro Castle
## 14      14     MV Princess Victoria
## 15      15      SS Admiral Nakhimov
## 16      16               MS Estonia
## 17      17 MS Princess of the Stars
## 18      18              MV Bulgaria

Notice that we selected two columns by name from the data frame called ships.

What is the Ship Id and Name of SHip for your assigned ship?

What is the row number for your ship?

For the RMS Titanic the row number is 8 and the Ship Id is 8. To find the Cause of the Titanic sinking I can use the code below. Try it and then add the code to find how your ship sank.

ships[8, "Cause"]
## [1] "Collision"
ships[15, "Cause"]
## [1] "Collision"

Find out whether the captain of your ship survived by using the variable “Survived.”

ships[15, "Survived"]
## [1] 1

What year did your ship sink?

ships[15, "Year"]
## [1] 1986

You can put more than one command in the same code chunk. In this code chunk find the Number of passengers, Number of women passengers, the length of the voyage, and the proportion of people on the ship who survived. You can add any additional variables that are of interest.

ships[15, c("No. of passengers", "No. of women passengers")]
##    No. of passengers No. of women passengers
## 15               897                     578
ships[15, "Length of voyage"]
## [1] 1
ships[15, "prop_survival"]
## [1] 0.6596943

Write a paragraph summarize the information about your ship.