
Every morning while taking subway i check my twitter account to see whats happening in the R world. Last week i came across a post and ended up learning about TidyTuesday initiative. The concept is simple the link is updated every monday with a new dataset and lets users to create visuals in R and post on twitter using the hashtag #tidytuesday.
I had participated in something similar called makeovermondays. This was specifically for tableau. But i ended up using R for generating visuals and it worked out well.
Initiatives like these allows us to get different perspectives about data and understand how other people are perceiving the same data. Anyways i tried my hand at this weeks Wine dataset. In this post i will provide the code i used and in next post i will try to break up my code and explain what my code is doing.
library(ggplot2) library(dplyr) library(packcircles) data <- read.csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-05-28/winemag-data-130k-v2.csv", stringsAsFactors = FALSE) prices <- data %>% group_by(country) %>% summarise(n = n(), prc = max(price, na.rm = TRUE))-> data_f data_f <- na.omit(data_f) packing <- circleProgressiveLayout(data_f$prc, sizetype='area') data_f = cbind(data_f, packing) dat.gg <- circleLayoutVertices(packing, npoints=50) # Make the plot ggplot() +# Make the bubbles
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
# Add text in the center of each bubble + control its size geom_text(data = data_f, aes(x, y, size=prc, label = country)) + scale_size_continuous(range = c(1,4)) +
# General theme:
theme_void() +
theme(legend.position="none",text=element_text(color = "white"), plot.background = element_rect(fill = "black")) +
coord_equal()
Leave a Reply