library(ggplot2)
library(gridExtra)
# Reading SEA data 
med = read.csv("~/Dropbox/Bao chi va Khoa hoc/Bong da va khoa hoc 2019/Medals of ASEAN countries.csv")
men = subset(med, Gender=="Men")
women = subset(med, Gender=="Women")
men = subset(med, Gender=="Men")
med$Medal = factor(med$Medal, levels=c("Gold", "Silver", "Bronze"))
men$Medal = factor(men$Medal, levels=c("Gold", "Silver", "Bronze"))
women$Medal = factor(women$Medal, levels=c("Gold", "Silver", "Bronze"))

Distribution of medals

# Plot for men 
p1 = ggplot(data=men, aes(x=reorder(Country, Number), y=Number, fill=Medal, label=Number)) + geom_bar(stat="identity") + coord_flip() + geom_text(size=3, col="white", position=position_stack(vjust=0.5)) + ylab("Percent") + theme(legend.position="top") +  labs(x="", y="Number of medals (men)")

# Plot for women 
p2 = ggplot(data=women, aes(x=reorder(Country, Number), y=Number, fill=Medal, label=Number)) + geom_bar(stat="identity") + coord_flip() + geom_text(size=3, col="white", position=position_stack(vjust=0.5)) + ylab("Percent") + theme(legend.position="top") +  labs(x="", y="Number of medals (women)")

grid.arrange(p1, p2, ncol=2)

# Reading Sci Publication data 1989 - 2019  

Country = c("Vietnam", "Thailand", "Malaysia", "Indonesia", "Singapore", "Philippines")
Pubs = c(43937, 120306, 158202, 53007, 211410, 24975)
dat = data.frame(Country, Pubs) 

pub = read.csv("~/Dropbox/Bao chi va Khoa hoc/Bong da va khoa hoc 2019/ISI Publications 1989-2019.csv")

Trend of ISI publications between 1989 and 2019

# Number of ISI publications 1989 - 2019 
p1 = ggplot(data=dat, aes(x=reorder(Country, Pubs), y=Pubs, col=Country, fill=Country, label=Pubs)) + geom_bar(stat="identity") + geom_text(col="white", hjust=1.2) + coord_flip() + labs(y="Number of Publications 1989 - 2019", x="") + theme(legend.position="none")

# Number of ISI publications 1989 - 2019 by year 
p2 = ggplot(data=pub, aes(x=Year, y=Pubs, col=Country)) + geom_line(lwd=1.2) + scale_x_continuous(breaks=seq(1989, 2019, 2)) + scale_y_continuous(breaks=seq(0, 18000, 2000)) + theme(legend.position="top")

library(gridExtra)
grid.arrange(p1, p2, ncol=2)