This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
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
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(Pclass))) +
geom_bar(fill = "pink") +
xlab("Passenger Class") +
ylab("Count") +
ggtitle("Count of Passengers by Class")
ggplot(titanic_data, aes(x = Embarked)) +
geom_bar(fill = "Green") +
xlab("Embarkation Point") +
ylab("Count") +
ggtitle("Count of Passengers by Embarkation Point")
ggplot(titanic_data, aes(x = Age, y = Fare)) +
geom_point(color = "red") +
xlab("Age") +
ylab("Fare") +
ggtitle("Scatter Plot of Age vs. Fare")
ggplot(titanic_data, aes(x = Age, y = Fare)) +
geom_point() +
facet_grid(. ~ Survived) +
xlab("Age") +
ylab("Fare") +
ggtitle("Age vs. Fare by Survival Status")
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.