titanic_data <- read.csv("cleaned_titanic_data.csv")

# installed and attached Necessary Packages
install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
names(titanic_data)
##  [1] "PassengerId" "Survived"    "Pclass"      "Name"        "Sex"        
##  [6] "Age"         "SibSp"       "Parch"       "Ticket"      "Fare"       
## [11] "Embarked"
names(titanic_data) <- tolower(names (titanic_data))
ggplot(titanic_data, aes(x = as.factor(survived))) +
  geom_bar() +
  xlab("survived") +
  ylab("Count") +
  ggtitle("Count of Survived Passengers")

ggplot(titanic_data, aes(x = age)) +
  geom_histogram(binwidth = 5, fill = "blue", color = "black") +
  xlab("Age") +
  ylab("Count") +
  ggtitle("Age Distribution of Passengers")

ggplot(titanic_data, aes(x = as.factor(survived), y = age)) +
  geom_boxplot() +
  xlab("survived") +
  ylab("sge") +
  ggtitle("Age Distribution by Survival Status")

ggplot(titanic_data, aes(x = as.factor(pclass))) +
  geom_bar(fill = "green") +
  xlab("Passenger Class") +
  ylab("Count") +
  ggtitle("Count of Passengers by Class")

ggplot(titanic_data, aes(x = embarked)) +
  geom_bar(fill = "purple") +
  xlab("Embarkation Point") +
  ylab("Count") +
  ggtitle("Count of Passengers by Embarkation Point")

ggplot(titanic_data, aes(x = age, y = fare)) +
  geom_point(color = "brown") +
  xlab("Age") +
  ylab("Fare") +
  ggtitle("Scatter Plot of Age vs. Fare")

ggplot(titanic_data, aes(x = age, y = fare)) +
  geom_point(color ="navy") +
  facet_grid(. ~ survived) +
  xlab("Age") +
  ylab("Fare") +
  ggtitle("Age vs. Fare by Survival Status")