This project uses the Titanic passenger dataset available through the Seaborn GitHub repository. The dataset contains information about Titanic passengers, including their survival status, passenger class, sex, age, fare, family relationships, and port of embarkation.
I selected this dataset because it has a clear outcome variable, survival status, and several passenger characteristics that may help explain differences in survival. It is also small enough to explore and transform without requiring complicated data preparation.
I plan to load the dataset directly from its raw GitHub URL so that the analysis can be reproduced on another computer. I will select variables related to passenger survival, rename abbreviated columns, and replace numerical categories with labels that are easier to interpret. I will then use summary tables to compare survival outcomes across passenger classes.
Some passenger ages and embarkation locations are missing from the dataset. The dataset also contains abbreviated column names and numerical categories that are not immediately understandable. For this introductory assignment, I will retain the missing values while documenting them and will transform the unclear names and categories into more descriptive labels.
The dataset is loaded directly from a raw GitHub URL. Loading the file from the web instead of from a local computer makes the analysis reproducible.
data_url <- "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv"
titanic_original <- read_csv(
file = data_url,
show_col_types = FALSE
)
glimpse(titanic_original)
## Rows: 891
## Columns: 15
## $ survived <dbl> 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1…
## $ pclass <dbl> 3, 1, 3, 1, 3, 3, 1, 3, 3, 2, 3, 1, 3, 3, 3, 2, 3, 2, 3, 3…
## $ sex <chr> "male", "female", "female", "female", "male", "male", "mal…
## $ age <dbl> 22, 38, 26, 35, 35, NA, 54, 2, 27, 14, 4, 58, 20, 39, 14, …
## $ sibsp <dbl> 1, 1, 0, 1, 0, 0, 0, 3, 0, 1, 1, 0, 0, 1, 0, 0, 4, 0, 1, 0…
## $ parch <dbl> 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 1, 0, 0, 5, 0, 0, 1, 0, 0, 0…
## $ fare <dbl> 7.2500, 71.2833, 7.9250, 53.1000, 8.0500, 8.4583, 51.8625,…
## $ embarked <chr> "S", "C", "S", "S", "S", "Q", "S", "S", "S", "C", "S", "S"…
## $ class <chr> "Third", "First", "Third", "First", "Third", "Third", "Fir…
## $ who <chr> "man", "woman", "woman", "woman", "man", "man", "man", "ch…
## $ adult_male <lgl> TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE,…
## $ deck <chr> NA, "C", NA, "C", NA, NA, "E", NA, NA, NA, "G", "C", NA, N…
## $ embark_town <chr> "Southampton", "Cherbourg", "Southampton", "Southampton", …
## $ alive <chr> "no", "yes", "yes", "yes", "no", "no", "no", "no", "yes", …
## $ alone <lgl> FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE,…
The original dataset contains 15 columns. For this analysis, I selected survival status, passenger class, sex, age, number of siblings or spouses aboard, number of parents or children aboard, fare, and embarkation town.
I also replaced the numerical survival values with descriptive labels and renamed several columns so their meanings are clearer.
titanic_selected <- titanic_original |>
select(
survived,
pclass,
sex,
age,
sibsp,
parch,
fare,
embark_town
) |>
rename(
survival_status = survived,
passenger_class = pclass,
passenger_sex = sex,
passenger_age = age,
siblings_spouses_aboard = sibsp,
parents_children_aboard = parch,
ticket_fare = fare,
embarkation_town = embark_town
) |>
mutate(
survival_status = case_when(
survival_status == 1 ~ "Survived",
survival_status == 0 ~ "Did not survive"
),
passenger_class = case_when(
passenger_class == 1 ~ "First class",
passenger_class == 2 ~ "Second class",
passenger_class == 3 ~ "Third class"
)
)
glimpse(titanic_selected)
## Rows: 891
## Columns: 8
## $ survival_status <chr> "Did not survive", "Survived", "Survived", "Su…
## $ passenger_class <chr> "Third class", "First class", "Third class", "…
## $ passenger_sex <chr> "male", "female", "female", "female", "male", …
## $ passenger_age <dbl> 22, 38, 26, 35, 35, NA, 54, 2, 27, 14, 4, 58, …
## $ siblings_spouses_aboard <dbl> 1, 1, 0, 1, 0, 0, 0, 3, 0, 1, 1, 0, 0, 1, 0, 0…
## $ parents_children_aboard <dbl> 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 1, 0, 0, 5, 0, 0…
## $ ticket_fare <dbl> 7.2500, 71.2833, 7.9250, 53.1000, 8.0500, 8.45…
## $ embarkation_town <chr> "Southampton", "Cherbourg", "Southampton", "So…
The following output displays the first ten rows of the transformed data frame.
head(titanic_selected, 10)
## # A tibble: 10 × 8
## survival_status passenger_class passenger_sex passenger_age
## <chr> <chr> <chr> <dbl>
## 1 Did not survive Third class male 22
## 2 Survived First class female 38
## 3 Survived Third class female 26
## 4 Survived First class female 35
## 5 Did not survive Third class male 35
## 6 Did not survive Third class male NA
## 7 Did not survive First class male 54
## 8 Did not survive Third class male 2
## 9 Survived Third class female 27
## 10 Survived Second class female 14
## # ℹ 4 more variables: siblings_spouses_aboard <dbl>,
## # parents_children_aboard <dbl>, ticket_fare <dbl>, embarkation_town <chr>
The following table counts the passengers in each survival category.
titanic_selected |>
count(survival_status)
## # A tibble: 2 × 2
## survival_status n
## <chr> <int>
## 1 Did not survive 549
## 2 Survived 342
This table compares survival status across the three passenger classes.
titanic_selected |>
count(passenger_class, survival_status)
## # A tibble: 6 × 3
## passenger_class survival_status n
## <chr> <chr> <int>
## 1 First class Did not survive 80
## 2 First class Survived 136
## 3 Second class Did not survive 97
## 4 Second class Survived 87
## 5 Third class Did not survive 372
## 6 Third class Survived 119
The completed data frame contains a subset of the original variables, including the target variable, survival status. Numerical values and abbreviated column names were replaced with labels that are easier to understand.
The work could be extended by calculating survival rates according to passenger class, sex, and age group. I could also examine missing age values, create visualizations, or compare these results with information from another historical Titanic dataset.
I used ChatGPT to help interpret the assignment requirements and to proofread my R code.
OpenAI. (2026). ChatGPT [Large language model]. https://chatgpt.com/. Accessed September 20, 2026.