Golem
Golem

Reputation: 126

How to plot a bar graph in R using ggplot

enter image description here

I'm trying to plot this graph using R but dont know how.

Screenshot of the dataset that I'm using

Upvotes: 0

Views: 76

Answers (1)

Bruno Mioto
Bruno Mioto

Reputation: 525

You didn't provide the dataset, but you could do something like that

# packages ----------------------------------------------------------------

library(dplyr)
library(ggplot2)

# data --------------------------------------------------------------------

#load your data first
#
#

#get just the last observation for each location
dataset2 <- dataset %>% 
  group_by(location) %>% 
  slice_tail() %>% 
  ungroup()

# plot --------------------------------------------------------------------

dataset2 %>% 
  ggplot(aes(x = continent, y = total_deaths))+
  geom_bar()

Upvotes: 1

Related Questions