I'm trying to create some pie charts showing the distribution of companies amongst regions and countries.
I'm getting an error saying 'x' values must be positive, which I think is because I'm trying to plot country names and it needs to be a number?
Any guidance on this would be really helpful
Summary: trying to make a pie chart of investor countries/regions to show their distribution (i.e. how many are in the UK, France, Germany etc)
Data: data
Main variables: investor, country/region
Any help with this code would be great!
Rory
try something on these lines
#demo data
investors <- paste0('investor', 1:100)
countries <- paste0('country', 1:5)
set.seed(1)
df <- data.frame(investors, countries = sample(countries, 100, T))
# pie chart code
library(tidyverse)
df %>% ggplot(aes(x = '', y = ..count.. , fill = countries)) +
geom_bar() +
coord_polar('y', start = 0)
Created on 2021-07-31 by the reprex package (v2.0.0)