Simple ggplot exercise

Author

Taylor Crockett

Published

February 8, 2023

Figure 1 is a brief comparison of Tsai Ing-Wen voters and non-voters on their sentiments about Taiwanese independence.

Code
library(haven)
library(ggplot2)
library(devtools)
library(dplyr)

TEDS_2016 <- read_stata("https://github.com/datageneration/home/blob/master/DataProgramming/data/TEDS_2016.dta?raw=true")

Tondulab <- "Position on unification and independence"

TEDS_2016$Tondu <- factor(TEDS_2016$Tondu, levels=c(1,2,3,4,5,6,9), 
                          labels=c("Unification now", 
                                   "Status quo, unif. in future", 
                                   "Status quo, decide later", 
                                   "Status quo forever", 
                                   "Status quo, indep. in future", 
                                   "Independence now", 
                                   "No response"))

TEDS_Tsai <- filter(TEDS_2016, votetsai==1)
TEDS_noTsai <- filter(TEDS_2016, votetsai==0)
TEDS_NATsai <- filter(TEDS_2016, is.na(votetsai))


ggplot(data=TEDS_2016, aes(x=x)) +
  geom_bar(data=TEDS_Tsai, aes(x = Tondu), 
                 fill="#00A36C") +
  geom_bar(data=TEDS_noTsai, aes(x = Tondu), 
                 fill= "#404080") +
  geom_bar(data=TEDS_NATsai, aes(x = Tondu), 
                 fill= "#808080") +
  xlab(Tondulab) + ylab("Count") + 
  theme(axis.text.x=element_text(angle=30,hjust=1) )

Figure 1: Position on Taiwanese independence respective of Tsai vote.