2

Basically this is what I'm going for:

Chart example

My data however is in this format:

Country Response
Spain No
France Yes
France No
France Yes
UK Yes

and basically would want to sum the "No" and "Yes" responses for each countryy

benson23
  • 16,369
  • 9
  • 19
  • 38
  • 2
    Maybe you can take a look at the [ggplot2 official website](https://ggplot2.tidyverse.org) to learn more about `ggplot`. This kind of graph is very straight forward to generate, I'm sure you can plot one after learning the basics of it :) – benson23 May 08 '22 at 11:07

1 Answers1

0

Here you go:

library(tidyverse)

# Generate some random data to work with
set.seed(123) 
Country <- rep(c("Spain", "France", "UK"), times = c(200,200,200))
Response <-  sample(c("Yes", "No"),600, replace = T, prob = c(.3,.6))
df <- data.frame(Country, Response)

# Barplot
p <- df %>%  ggplot(aes(x = Country, fill = Response)) +
  geom_bar(position=position_dodge()) +
  ggtitle("Response of each country") +
  xlab("") +
  ylab("") +
  theme_bw() +
  theme(plot.title = element_text(size = 12, face = "bold", hjust = 0.5))
  
p

I have added a few extra lines so you can play around with it.

U_jex
  • 83
  • 6