Xinxin Yang's avatar
Xinxin Yang committed
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
figure(new_lst$NED)
figure <- function(df){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = 32)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
figure(new_lst$NED)
figure <- function(df){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = 35)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
figure(new_lst$NED)
for (i in 1:28){
p <- figure(new_lst[[i]])
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 12, height = 8)
}
figure <- function(df){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = 20)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
new_lst[[1]]
names(new_lst[[1]])
figure <- function(df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = "Number of common ID", fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(new_lst[[i]], 35)
}
else{
p <- figure(new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 12, height = 8)
}
NED <- figure(new_lst$NED, 35)
NED <- figure(new_lst$NED, 35)
NED
ggsave(plot = NED,
filename = paste0(get.data.dir(),"/plots/","NED_" ,"_plot.png"),
width = 12, height = 8)
ggsave(plot = NED,
filename = paste0(get.data.dir(),"/plots/","NED_" ,"_plot.png"),
width = 15, height = 8)
ggsave(plot = NED,
filename = paste0(get.data.dir(),"/plots/","NED_" ,"_plot.png"),
width = 18, height = 8)
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(new_lst[[i]], 35)
}
else{
p <- figure(new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
labs(title = paste0("Plot of the Number of common ID for country:", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+
geom_bar( stat="identity",position = position_dodge(width = 0.8),width=0.5, fill = "limegreen" ) +
coord_flip()+
#labs(title = paste0("Plot of the Number of common ID for country: ", country ), fill = "Years") +
xlab("Years") +
ylab("Number of common ID") +
geom_text(aes(label=Num_id), vjust=0.5, colour="black", size=3.5)+
theme(axis.text.x=element_text(color = "black", size=6, angle=0, vjust=.8, hjust=0.8)) +
# other 20, NED = 35
scale_x_discrete(labels = function(x) str_wrap(x, width = n)) +
facet_wrap( ~ group, scales="free",
labeller=names
#labeller(group = label_facet(df$group, "grouping"))
)+
ggtitle(paste0("Plot of the number of common ID for country: ", country )) +
ggeasy::easy_center_title() +
theme_bw()
p
}
for (i in 1:28){
if (sheetsnames[i] =="NED"){
p <- figure(sheetsnames[i],new_lst[[i]], 35)
}
else{
p <- figure(sheetsnames[i],new_lst[[i]], 20)
}
ggsave(plot = p,
filename = paste0(get.data.dir(),"/plots/",sheetsnames[i] ,"_plot.png"),
width = 18, height = 8)
}
figure <- function(country, df, n){
p = df %>%
#ggplot( aes(x = reorder(Years, -Num_id) ,y=Num_id))
ggplot( aes(x = Years ,y=Num_id))+