data <- read.csv("C:/Users/Helfira/Downloads/titanic.csv")
View(data)
titanic <- data %>% as_tibble()
p2 <- titanic %>%
group_by(Survived, Sex) %>%
summarise(count = n(), .groups = "drop") %>%
plot_ly(x = ~Sex, y = ~count, color = ~Survived, type = "bar", colors = c("#F4DF58", "#D580FF")) %>%
layout(title = "Survival by Gender",
xaxis = list(title = "Gender"),
yaxis = list(title = "Count"))
p2
## Warning: textfont.color doesn't (yet) support data arrays
## Warning: textfont.color doesn't (yet) support data arrays
p1 <- plot_ly(titanic, labels = ~Survived, type = "pie",
marker = list(colors = c("#FF6F6F", "#169c4e"))) %>%
layout(title = "survivel count by age")
p1
p3 <- titanic %>%
group_by(Survived, Pclass) %>%
summarise(count = n(), .groups = "drop") %>%
plot_ly(x = ~Pclass, y = ~count, color = ~Survived, type = "bar", colors = c("#7AD3FF", "#F882AE")) %>%
layout(title = "Survival by Class",
xaxis = list(title = "Class"),
yaxis = list(title = "Count"))
p3
## Warning: textfont.color doesn't (yet) support data arrays
## Warning: textfont.color doesn't (yet) support data arrays
trace1 <- list(
y = titanic$Age,
name = "Survived",
type = "box",
marker = list(color = "#63ace0")
)
trace2 <- list(
y = titanic$Age,
name = "Not Survived",
type = "box",
marker = list(color = "#169c4e")
)
p4 <- plotly_build(list(data = list(trace1, trace2))) %>%
layout(title = "Survival by Age Group",
xaxis = list(title = "Survival Status"),
yaxis = list(title = "Age"))
p4
Passenger Survival Pie Chart: This pie chart shows the proportion of passengers who survived and who did not survive the Titanic disaster. The chart is based on the “Survived” variable in the dataset, which has two possible values: 0 (did not survive) and 1 (survived). The chart is divided into two sections, each representing one of these values. The chart suggests that a significant proportion of the passengers did not survive the disaster.
Survival by Gender Bar Chart: This bar chart shows the number of passengers who survived and did not survive the disaster, based on their gender. The chart is based on two variables in the dataset, “Survived” and “Sex”. The chart shows two bars for each gender,each one representing the number of passengers who survived and the number of passengers who did not survive. The chart suggests that a higher proportion of female passengers survived the disaster than male passengers.
Survival by Class Bar Chart: This bar chart shows the number of passengers who survived and did not survive the disaster, based on their class. The chart is based on two variables in the dataset, “Survived” and “Pclass” (passenger class). The chart shows three bars for each class, each one representing the number of passengers who survived and the number of passengers who did not survive. The chart suggests that a higher proportion of passengers in first class survived the disaster compared to passengers in second and third class.
Survival by Age Group Box Plot: This box plot shows the distribution of age for passengers who survived and did not survive the disaster. The plot is based on the “Age” variable in the dataset, and it is divided into two boxes, one representing the age distribution of passengers who survived and the other representing the age distribution of passengers who did not survive. The boxes show the quartiles of the age distribution, with the horizontal line in the box representing the median age. The chart suggests that there is no significant difference in the age distribution between passengers who survived and those who did not survive the disaster.
Overall, the four plots provide complementary information about the factors that influenced the survival of passengers on the Titanic, highlighting the importance of gender and passenger class over age.