library(fivethirtyeight)
library(tidyr)
library(tidyverse)
data = fivethirtyeight::drinks
data2 <- data %>% filter(country=='USA'|country=='Seychelles'|country=='Iceland'|country=='Greece')
#reshape from wide to long.
data2_long <- gather(data2,type,servings,beer_servings,spirit_servings,wine_servings)
data2_long$country <- factor(data2_long$country)
data2_long$type <- factor(data2_long$type)
levels(data2_long$type) <- c("beer","spirit","wine")
data2_long <- data2_long[order(data2_long$country,data2_long$type), ]
data2_long <- data2_long %>% arrange(desc(country))
# Grouped
ggplot(data2_long, aes(fill=type, y=country, x=servings)) +
geom_bar(position="dodge", stat="identity")
