library(tidyverse)
library(tidygraph)
library(igraph)
library(bibliometrix)
library(tosr)
library(here)
library(lubridate)
library(sjrdata)
library(openxlsx)
library(zoo)
library(RSQLite)
library(journalabbr)
library(ggraph)
library(openxlsx)
library(XML)
library(plyr)
source("verbs.R")
giant.component <- function(graph) {
cl <- igraph::clusters(graph)
igraph::induced.subgraph(graph,
which(cl$membership == which.max(cl$csize)))
}
wos_scopus_tos <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=449678767")
wos <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=449678767") # create dataframe from wos file
scopus <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=2048544658")
reference_df <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=427285529")
journal_df <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=1678374455")
author_df <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=809075514")
figure_1_data <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=357523736")
TC_all <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=1138484187")
table_2 <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=1737058443")
wos_scopus_total_journal <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=1092432429")
wos_scopus_authors <-
read_csv("https://docs.google.com/spreadsheets/d/1bvWHpDP0Mug-otEh_SmHLtGthVDoF7OpCRS6yo-oBWM/export?format=csv&gid=921248754")
figure_1a <-
figure_1_data |>
pivot_longer(!PY, names_to = "ref_type", values_to = "n") |>
filter(ref_type != "total") |>
ggplot(aes(x = factor(PY),
y = n,
fill = ref_type)) +
geom_bar(stat = "identity",
position = "dodge") +
geom_text(aes(label = n),
vjust = -0.3,
position = position_dodge(0.9),
size = 3,
family = "Times") +
scale_fill_manual(values = c("springgreen3",
"orange3")) +
theme(text = element_text(family = "Times",
face = "bold",
size =12),
panel.background = element_rect(fill = "white"),
legend.position = "bottom",
legend.title = element_text(size = 0),
axis.text.x = element_text(face = "bold",
angle = 45,
vjust = 0.5),
axis.line = element_line(color = "black",
size = 0.2)) +
labs(y = "Number of publications",
x = "Year")
figure_1a
figure_1b <-
figure_1_data |>
ggplot(aes(x = PY, y = total)) +
geom_line(stat = "identity", color = "red") +
geom_point(stat = "identity", color = "red") +
scale_x_continuous(breaks = seq(2000, year(today()) - 1, by = 1)) +
geom_text(aes(label = total),
vjust = -0.3,
position = position_dodge(0.9),
size = 3,
family = "Times",
color = "red") +
scale_fill_manual(values = c("springgreen3",
"orange3")) +
theme(text = element_text(family = "Times",
face = "bold",
size =12),
panel.background = element_rect(fill = "white"),
legend.position = "bottom",
legend.title = element_text(size = 0),
axis.text.x = element_text(face = "bold",
angle = 45,
vjust = 0.5),
axis.line = element_line(color = "black",
size = 0.2)) +
labs(y = "Number of total publications",
x = "Year")
figure_1b
figure_1c <-
TC_all |>
ggplot(aes(x = PY , y = TC_sum_all)) +
geom_line(stat = "identity", color = "purple") +
geom_point(color = "purple") +
scale_x_continuous(breaks = seq(2000, year(today()) - 1 , by = 1)) +
geom_text(aes(label = TC_sum_all),
vjust = -0.3,
position = position_dodge(0.9),
size = 3,
family = "Times",
color = "purple") +
scale_fill_manual(values = c("springgreen3",
"orange3")) +
theme(text = element_text(family = "Times",
face = "bold",
size =12),
panel.background = element_rect(fill = "white"),
legend.position = "bottom",
legend.title = element_text(size = 0),
axis.text.x = element_text(face = "bold",
angle = 45,
vjust = 0.5),
axis.line = element_line(color = "black",
size = 0.2)) +
labs(y = "Number of citations",
x = "Year")
figure_1c
table_2 |>
DT::datatable(class = "cell-border stripe",
rownames = F,
filter = "top",
editable = FALSE,
extensions = "Buttons",
options = list(dom = "Bfrtip",
buttons = c("copy",
"csv",
"excel",
"pdf",
"print")))
Export wos_scopus_tos and upload it to biblioshiny
wos_scopus_total_journal |>
DT::datatable(class = "cell-border stripe",
rownames = F,
filter = "top",
editable = FALSE,
extensions = "Buttons",
options = list(dom = "Bfrtip",
buttons = c("copy",
"csv",
"excel",
"pdf",
"print")))
Creating the graph object
journal_citation_graph_weighted_tbl_small <-
journal_df |>
dplyr::select(JI_main, JI_ref) |>
dplyr::group_by(JI_main, JI_ref) |>
dplyr::count() |>
dplyr::rename(weight = n) |>
as_tbl_graph(directed = FALSE) |>
# convert(to_simple) |>
activate(nodes) |>
dplyr::mutate(components = tidygraph::group_components(type = "weak")) |>
dplyr::filter(components == 1) |>
activate(nodes) |>
dplyr::mutate(degree = centrality_degree(),
community = tidygraph::group_louvain()) |>
dplyr::select(-components) |>
dplyr::filter(degree >= 1)
# activate(edges) |>
# dplyr::filter(weight != 1)
communities <-
journal_citation_graph_weighted_tbl_small |>
activate(nodes) |>
data.frame() |>
dplyr::count(community, sort = TRUE) |>
dplyr::slice(1:10) |>
dplyr::select(community) |>
dplyr::pull()
# Filtering biggest communities
journal_citation_graph_weighted_tbl_small_fig <-
journal_citation_graph_weighted_tbl_small |>
activate(nodes) |>
dplyr::filter(community %in% communities)
Selecting nodes to show
jc_com_1 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[1]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_2 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[2]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_3 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[3]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_4 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[4]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_5 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[5]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_6 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[6]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_7<-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[7]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_8 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[8]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_9 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[9]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com_10 <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(community == communities[10]) |>
dplyr::mutate(degree = centrality_degree()) |>
dplyr::arrange(desc(degree)) |>
dplyr::slice(1:10) |>
data.frame() |>
dplyr::select(name)
jc_com <-
jc_com_1 |>
bind_rows(jc_com_2,
jc_com_3,
# jc_com_4,
# jc_com_5,
# jc_com_6,
# jc_com_7,
# jc_com_8,
# jc_com_9,
# jc_com_10
)
figure_3a <-
journal_citation_graph_weighted_tbl_small_fig |>
activate(nodes) |>
dplyr::filter(name %in% jc_com$name) |>
dplyr::mutate(degree = centrality_degree(),
community = factor(community)) |>
dplyr::filter(degree != 0) |>
ggraph(layout = "graphopt") +
geom_edge_link(aes(width = weight),
colour = "lightgray") +
scale_edge_width(name = "Link strength") +
geom_node_point(aes(color = community,
size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
scale_size(name = "Degree") +
# scale_color_binned(name = "Communities") +
theme_graph()
figure_3a
figure_3b <-
journal_citation_graph_weighted_tbl_small |>
activate(nodes) |>
data.frame() |>
dplyr::select(community) |>
dplyr::count(community, sort = TRUE) |>
dplyr::slice(1:10) |>
ggplot(aes(x = reorder(community, n), y = n)) +
geom_point(stat = "identity") +
geom_line(group = 1) +
# geom_text(label = as.numeric(community),
# nudge_x = 0.5,
# nudge_y = 0.5,
# check_overlap = T) +
labs(title = "Communities by size",
x = "communities",
y = "Journals") +
theme(text = element_text(color = "black",
face = "bold",
family = "Times New Roman"),
plot.title = element_text(size = 25),
panel.background = element_rect(fill = "white"),
axis.text.y = element_text(size = 15,
colour = "black"),
axis.text.x = element_text(size = 15,
colour = "black"),
axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20))
figure_3b