-
Notifications
You must be signed in to change notification settings - Fork 2
/
Scimago_v3.R
180 lines (151 loc) · 7.72 KB
/
Scimago_v3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
gc()
library(tidyverse)
library(readxl)
library(bayestestR)
library(gridExtra)
#### Overall citations----
## Load and prepare data
## Source: Scimago Country Rankings (Latin America) - https://www.scimagojr.com/countryrank.php
files.la <- list.files(path="Scimago/LA",
pattern = ".xlsx", full.names = TRUE)
years <- 2000:2019
la.countries <- list()
for(i in 1:length(files.la)){
la.countries[[i]] <- read_excel(files.la[i])
la.countries[[i]] <- la.countries[[i]] %>% mutate(year=years[i])
}
la.countriesF <- bind_rows(la.countries)
la.countriesF <- la.countriesF %>% rename(Citable_documents = "Citable documents", Self_citations = "Self-citations",
Citations_per_document = "Citations per document", H_index = "H index")
## Visualize data
la.countriesF
unique(la.countriesF$Country)
la.countriesF %>% filter(year==2019) %>% arrange(desc(Citable_documents))
la.countriesF %>% filter(Country=="Brazil") %>% ggplot(aes(x=year, y=Documents)) + geom_line()
la.countriesF %>% filter(Country=="Brazil") %>% ggplot(aes(x=year, y=Citations_per_document)) + geom_line()
la.countriesF %>% filter(Country=="Brazil") %>% ggplot(aes(x=year, y=Self_citations)) + geom_line()
## Plot overall citations over time for top 5 LA countries (Fig. 1)
pal <- c("cyan", "green", "blue3", "yellow", "red")
cit <- la.countriesF %>% filter(Country %in% c("Brazil", "Mexico", "Chile", "Argentina", "Colombia")) %>%
ggplot(aes(x=year, y=Citations_per_document, group = Country)) +
geom_point(aes(size=Citable_documents, color=Country)) +
scale_size_continuous(range = c(1,10)) +
geom_line(aes(color=Country), size=2, alpha=0.75) +
scale_x_continuous(breaks = c(2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018)) +
scale_colour_manual(values=pal) + geom_vline(xintercept=2009, color="black", linetype="dashed", size=1) +
ylab("Citations per document") + xlab("Year") +
guides(fill=guide_legend(title="Country"), size=guide_legend(title="Citable documents")) +
theme_minimal() + theme(
legend.position = "bottom",
legend.title=element_text(size=10, face="bold"),
legend.text=element_text(size=10),
axis.title.x = element_text(size=15, face="bold"),
axis.title.y = element_text(size=15, face="bold"))
cit
ggsave("LA_countries.png", width = 28, height = 18, units = "cm", dpi = 300)
ggsave("LA_countries.tif", plot = cit, device = "tiff", width = 28, height = 18, units = "cm", dpi = 300)
## Overall documents over time (not shown in the preprint)
doc <- la.countriesF %>% filter(Country %in% c("Brazil", "Mexico", "Chile", "Argentina", "Colombia")) %>%
ggplot(aes(x=year, y=Citable_documents/1000, group = Country)) +
geom_line(aes(color=Country), size=2, alpha=0.75) +
scale_colour_manual(values=pal) + geom_vline(xintercept=2009, color="black", linetype="dashed", size=1) +
ylab("Citable documents (x 1000)") + xlab(NULL) +
theme_minimal() + theme(
legend.position = "none",
#legend.title=element_text(size=15, face="bold"),
#legend.text=element_text(size=15),
axis.title.x = element_text(size=15, face="bold"),
axis.title.y = element_text(size=15, face="bold"))
doc
ga.plot <- grid.arrange(doc, cit, ncol=1)
ggsave(file="LA_countries2.png", ga.plot, width = 20, height = 20, units = "cm", dpi = 300)
#### AUC 1 ----
Brazil_pre <- la.countriesF %>% filter(Country %in% c("Brazil"), year<=2009)
Brazil_pos <- la.countriesF %>% filter(Country %in% c("Brazil"), year>2009)
Mexico_pre <- la.countriesF %>% filter(Country %in% c("Mexico"), year<=2009)
Mexico_pos <- la.countriesF %>% filter(Country %in% c("Mexico"), year>2009)
Chile_pre <- la.countriesF %>% filter(Country %in% c("Chile"), year<=2009)
Chile_pos <- la.countriesF %>% filter(Country %in% c("Chile"), year>2009)
Argentina_pre <- la.countriesF %>% filter(Country %in% c("Argentina"), year<=2009)
Argentina_pos <- la.countriesF %>% filter(Country %in% c("Argentina"), year>2009)
Colombia_pre <- la.countriesF %>% filter(Country %in% c("Colombia"), year<=2009)
Colombia_pos <- la.countriesF %>% filter(Country %in% c("Colombia"), year>2009)
auc_scimago <- function(data){
res <- area_under_curve(x=data$year, y=data$Citations_per_document, method="trapezoid")
return(res)
}
nrow(Brazil_pre)
nrow(Brazil_pos)
aucTable <- data.frame(Country = c("Brazil", "Mexico", "Chile", "Argentina", "Colombia"),
AUC.2000_2009 = NA, AUC.2009_2019 = NA)
aucTable[1, 2] <- auc_scimago(Brazil_pre)
aucTable[1, 3] <- auc_scimago(Brazil_pos)
aucTable[2, 2] <- auc_scimago(Mexico_pre)
aucTable[2, 3] <- auc_scimago(Mexico_pos)
aucTable[3, 2] <- auc_scimago(Chile_pre)
aucTable[3, 3] <- auc_scimago(Chile_pos)
aucTable[4, 2] <- auc_scimago(Argentina_pre)
aucTable[4, 3] <- auc_scimago(Argentina_pos)
aucTable[5, 2] <- auc_scimago(Colombia_pre)
aucTable[5, 3] <- auc_scimago(Colombia_pos)
write.csv(aucTable, file="aucTable.csv", row.names=FALSE)
#### Brazilian Physics and Social Work citations ----
## Load and prepare data
## Source: Scimago Country Rankings (Latin America) - https://www.scimagojr.com/countryrank.php
files.ph <- list.files(path="Scimago/Physics",
pattern = ".xlsx", full.names = TRUE)
years <- 2009:2019
ph.countries <- list()
for(i in 1:length(files.ph)){
ph.countries[[i]] <- read_excel(files.ph[i])
ph.countries[[i]] <- ph.countries[[i]] %>% mutate(year=years[i])
}
ph.countries
ph.countriesF <- bind_rows(ph.countries)
ph.countriesF <- ph.countriesF %>%
rename(Citable_documents = "Citable documents", Self_citations = "Self-citations",
Citations_per_document = "Citations per document", H_index = "H index") %>%
mutate(Area = "Physics and Astronomy")
ph.countriesF
files.sw <- list.files(path="Scimago/SocialWork",
pattern = ".xlsx", full.names = TRUE)
years <- 2009:2019
sw.countries <- list()
for(i in 1:length(files.sw)){
sw.countries[[i]] <- read_excel(files.sw[i])
sw.countries[[i]] <- sw.countries[[i]] %>% mutate(year=years[i])
}
sw.countries
sw.countriesF <- bind_rows(sw.countries)
sw.countriesF <- sw.countriesF %>%
rename(Citable_documents = "Citable documents", Self_citations = "Self-citations",
Citations_per_document = "Citations per document", H_index = "H index") %>%
mutate(Area = "Social Work")
ph.countriesF
sw.countriesF
com.countries <- bind_rows(ph.countriesF, sw.countriesF)
com.countries
unique(com.countries$Area)
## Plot citations in time for Brazilian physics and social work (Fig. 4)
ph.sw <- com.countries %>% filter(Country %in% c("Brazil")) %>%
ggplot(aes(x=year, y=Citations_per_document, group = Area)) +
geom_point(aes(color=Area)) + #, size=Citable_documents
geom_line(aes(color=Area), size=2, alpha=0.75) +
#geom_smooth(method="gam", se=FALSE, aes(color=Area), size=2) +
scale_x_continuous(breaks = c(2009, 2011, 2013, 2015, 2017, 2019)) +
ylab("Citations per document") + xlab("Year") +
#guides(fill=guide_legend(title="Area"), size=guide_legend(title="Citable documents")) +
theme_minimal() + theme(
legend.position = "bottom",
legend.title=element_text(size=10, face="bold"),
legend.text=element_text(size=10),
axis.title.x = element_text(size=15, face="bold"),
axis.title.y = element_text(size=15, face="bold"))
ph.sw
ggsave(file="Physics_vs_SW.png", width = 20, height = 15, units = "cm", dpi = 300)
ggsave(file="Physics_vs_SW.tif", plot = ph.sw, device = "tiff", width = 20, height = 15, units = "cm", dpi = 300)
#### AUC 2 ----
auc.ph <- com.countries %>% filter(Country %in% c("Brazil")) %>% filter(Area == "Physics and Astronomy")
auc.sw <- com.countries %>% filter(Country %in% c("Brazil")) %>% filter(Area == "Social Work")
area_under_curve(x=auc.ph$year, y=auc.ph$Citations_per_document, method="trapezoid")
area_under_curve(x=auc.sw$year, y=auc.sw$Citations_per_document, method="trapezoid")