My original code for plotting makes a deceptive plot because it over plots the different subsets of survived and you could only see the tallest element. Each apparent bar is the over plotting of every combination of Female/Male and Adult/Child. In the following code, I first sum up all of the subsets for each combination of survived and Class and then plot the data with labels showing the exact values.
survival <- structure(list(Class = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L),
.Label = c("1st", "2nd", "3rd", "Crew"),
class = "factor"),
Survived = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L),.Label = c("No", "Yes"), class = "factor"),
Sex = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L),
.Label = c("Male", "Female"), class = "factor"),
Age = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L),
.Label = c("Child", "Adult"), class = "factor"),
Freq = c(0, 0, 35, 0, 0, 0, 17, 0, 118, 154, 387, 670, 4, 13, 89, 3, 5, 11, 13, 0, 1, 13, 14, 0,
57, 14, 75, 192, 140, 80, 76, 20)),
row.names = c(NA, -32L), class = "data.frame")
library(ggplot2)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
SummarySurvival <- survival %>% group_by(Class, Survived) %>% summarize(Total = sum(Freq))
#> `summarise()` regrouping output by 'Class' (override with `.groups` argument)
SummarySurvival
#> # A tibble: 8 x 3
#> # Groups: Class [4]
#> Class Survived Total
#> <fct> <fct> <dbl>
#> 1 1st No 122
#> 2 1st Yes 203
#> 3 2nd No 167
#> 4 2nd Yes 118
#> 5 3rd No 528
#> 6 3rd Yes 178
#> 7 Crew No 673
#> 8 Crew Yes 212
ggplot(SummarySurvival, aes(x = Survived, y = Total, fill = Class)) +
geom_col(position = position_dodge())+
geom_text(aes(label = Total), position = position_dodge(width = 0.9), vjust = 0) +
labs(y="Number of Passangers",
title = "Survival Rates by Class")

Created on 2021-04-29 by the reprex package (v0.3.0)