Search code examples
rggplot2dplyrtidyverse

How to plot barplots using ggplot in R


I was trying to create a barplot using ggplot but couldn't get the right result. This is my data set:

enter image description here

I'm trying to create a barplot like this: enter image description here


Solution

  • You would do (assuming your dataframe is called d):

    library(tidyverse)
    d %>%
      ggplot(aes(x = continent, y = continental_sum)) +
      geom_bar(stat = "identity", fill = "blue") +
      labs(
       title = "Total Death Per Continent",
       y = "Total Death Count",
       x = ""
    )