Using ggplot2 to create a bar chart
The number of people in each category is not defined by the number of rows but by the number in the Freq column. You therefore have to take the sum of those values and plot the result, this can be done by supplying the column which holds the value you want to use on the y-axis to aes() and use stat=&quot;identity&quot; for geom_bar:
library(tidyverse)
library(titanic)

titanic &lt;- as.data.frame(Titanic)
titanic$Survived &lt;- as.factor(titanic$Survived)

ggplot(titanic, aes(Survived, Freq, fill = Survived))+
  geom_bar(stat=&quot;identity&quot;)+
  ggtitle(&quot;Barplot to represent Passenger Count who Survived vs who Died&quot;)