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)
library(readxl)
source("verbs.R")
windowsFonts("Times" = windowsFont("Times"))
windowsFonts("Times New Roman" = windowsFont("Times New Roman"))
giant.component <- function(graph) {
cl <- igraph::clusters(graph)
igraph::induced.subgraph(graph,
which(cl$membership == which.max(cl$csize)))
}
library(readxl)
library(httr)
tf<-"C:/coreR/UNAD_Toc/all_data_sustaibale_toursim_ariza_10.xlsx"
wos_scopus <- readxl::read_excel(tf,sheet = 1)
wos <- readxl::read_excel(tf, sheet = 2)
scopus <- readxl::read_excel(tf, sheet = 3)
## Warning: Expecting logical in H1388 / R1388C8: got 'CHANIA, CRETE'
## Warning: Expecting logical in H1389 / R1389C8: got 'BARCELONA'
## Warning: Expecting logical in H1390 / R1390C8: got 'BUDAPEST'
## Warning: Expecting logical in H1391 / R1391C8: got 'HERAKLION, CRETE'
## Warning: Expecting logical in H1392 / R1392C8: got 'KUCHING, SARAWAK'
## Warning: Expecting logical in H1396 / R1396C8: got 'MINNEAPOLIS, MN'
## Warning: Expecting logical in H1398 / R1398C8: got 'PIRAEUS-ATHENS'
## Warning: Expecting logical in H1399 / R1399C8: got 'BOURNEMOUTH, DORSET'
## Warning: Expecting logical in H1400 / R1400C8: got 'MARSEILLE'
## Warning: Expecting logical in H1401 / R1401C8: got 'MARSEILLE'
## Warning: Expecting logical in H1402 / R1402C8: got 'MARSEILLE'
## Warning: Expecting logical in H1403 / R1403C8: got 'MARSEILLE'
## Warning: Expecting logical in H1404 / R1404C8: got 'MARSEILLE'
## Warning: Expecting logical in H1405 / R1405C8: got 'MARSEILLE'
## Warning: Expecting logical in H1406 / R1406C8: got 'MARSEILLE'
## Warning: Expecting logical in H1407 / R1407C8: got 'MARSEILLE'
## Warning: Expecting logical in H1408 / R1408C8: got 'MARSEILLE'
## Warning: Expecting logical in H1409 / R1409C8: got 'MARSEILLE'
## Warning: Expecting logical in H1410 / R1410C8: got 'MARSEILLE'
## Warning: Expecting logical in H1411 / R1411C8: got 'MARSEILLE'
## Warning: Expecting logical in H1412 / R1412C8: got 'MARSEILLE'
## Warning: Expecting logical in H1413 / R1413C8: got 'MARSEILLE'
## Warning: Expecting logical in H1414 / R1414C8: got 'MARSEILLE'
## Warning: Expecting logical in H1415 / R1415C8: got 'MARSEILLE'
## Warning: Expecting logical in H1416 / R1416C8: got 'MARSEILLE'
## Warning: Expecting logical in H1417 / R1417C8: got 'MARSEILLE'
## Warning: Expecting logical in H1418 / R1418C8: got 'MARSEILLE'
## Warning: Expecting logical in H1419 / R1419C8: got 'KYOTO'
## Warning: Expecting logical in H1422 / R1422C8: got 'SAN JOSE, CA'
## Warning: Expecting logical in H1423 / R1423C8: got 'LISBON'
## Warning: Expecting logical in H1424 / R1424C8: got 'NAPLES'
## Warning: Expecting logical in H1428 / R1428C8: got 'BEIJING'
## Warning: Expecting logical in H1430 / R1430C8: got 'JINAN'
## Warning: Expecting logical in H1432 / R1432C8: got 'LOS ANGELES, CA'
## Warning: Expecting logical in H1434 / R1434C8: got 'MUNICH'
## Warning: Expecting logical in H1435 / R1435C8: got 'CHOLULA, PUEBLA'
## Warning: Expecting logical in H1436 / R1436C8: got 'HO CHI MINH CITY'
## Warning: Expecting logical in H1438 / R1438C8: got 'BURLINGAME, CA'
## Warning: Expecting logical in H1439 / R1439C8: got 'DAEJEON'
## Warning: Expecting logical in H1440 / R1440C8: got 'FUZHOU'
## Warning: Expecting logical in H1456 / R1456C8: got 'ISTANBUL'
## Warning: Expecting logical in H1457 / R1457C8: got 'KYOTO'
## Warning: Expecting logical in H1458 / R1458C8: got 'KYOTO'
## Warning: Expecting logical in H1459 / R1459C8: got 'ALBENA'
## Warning: Expecting logical in H1460 / R1460C8: got 'PUERTO DE LA CRUZ,
## TENERIFE'
## Warning: Expecting logical in H1461 / R1461C8: got 'PUERTO DE LA CRUZ,
## TENERIFE'
## Warning: Expecting logical in H1462 / R1462C8: got 'PUERTO DE LA CRUZ,
## TENERIFE'
## Warning: Expecting logical in H1465 / R1465C8: got 'LAS VEGAS, NV'
## Warning: Expecting logical in H1467 / R1467C8: got 'LAS VEGAS, NV'
## Warning: Expecting logical in H1469 / R1469C8: got 'NARA'
## Warning: Expecting logical in H1471 / R1471C8: got 'KYOTO'
## Warning: Expecting logical in H1472 / R1472C8: got 'TAMPERE'
## Warning: Expecting logical in H1474 / R1474C8: got 'ATLANTA, GA'
## Warning: Expecting logical in H1475 / R1475C8: got 'CHENNAI'
## Warning: Expecting logical in H1477 / R1477C8: got 'MILAN'
## Warning: Expecting logical in H1478 / R1478C8: got 'MILAN'
## Warning: Expecting logical in H1479 / R1479C8: got 'MILAN'
## Warning: Expecting logical in H1480 / R1480C8: got 'MILAN'
## Warning: Expecting logical in H1481 / R1481C8: got 'MILAN'
## Warning: Expecting logical in H1482 / R1482C8: got 'MILAN'
## Warning: Expecting logical in H1483 / R1483C8: got 'MILAN'
## Warning: Expecting logical in H1484 / R1484C8: got 'MILAN'
## Warning: Expecting logical in H1485 / R1485C8: got 'MILAN'
## Warning: Expecting logical in H1486 / R1486C8: got 'MILAN'
## Warning: Expecting logical in H1487 / R1487C8: got 'ROCHESTER, NY'
## Warning: Expecting logical in H1488 / R1488C8: got 'GUIMARAES'
## Warning: Expecting logical in H1489 / R1489C8: got 'GENOVA'
## Warning: Expecting logical in H1490 / R1490C8: got 'LIMASSOL'
## Warning: Expecting logical in H1491 / R1491C8: got 'LIMASSOL'
## Warning: Expecting logical in H1492 / R1492C8: got 'LIMASSOL'
## Warning: Expecting logical in H1493 / R1493C8: got 'DAEJEON'
## Warning: Expecting logical in H1495 / R1495C8: got 'SALVADOR DE BAHIA'
## Warning: Expecting logical in H1496 / R1496C8: got 'LONDON'
## Warning: Expecting logical in H1498 / R1498C8: got 'COSTA MESA, CA'
## Warning: Expecting logical in H1504 / R1504C8: got 'VIENNA'
## Warning: Expecting logical in H1506 / R1506C8: got 'CHANGCHUN'
## Warning: Expecting logical in H1510 / R1510C8: got 'BASEL'
## Warning: Expecting logical in H1511 / R1511C8: got 'BASEL'
## Warning: Expecting logical in H1512 / R1512C8: got 'BASEL'
## Warning: Expecting logical in H1513 / R1513C8: got 'CAMBRIDGE'
## Warning: Expecting logical in H1514 / R1514C8: got 'HOBART, TAS'
## Warning: Expecting logical in H1516 / R1516C8: got 'ROME'
## Warning: Expecting logical in H1517 / R1517C8: got 'JINAN'
## Warning: Expecting logical in H1518 / R1518C8: got 'SARAJEVO'
## Warning: Expecting logical in H1520 / R1520C8: got 'TAIPEI'
## Warning: Expecting logical in H1521 / R1521C8: got 'TAIPEI'
## Warning: Expecting logical in H1522 / R1522C8: got 'LISBON'
## Warning: Expecting logical in H1530 / R1530C8: got 'LONDON'
## Warning: Expecting logical in H1531 / R1531C8: got 'ATHENS'
## Warning: Expecting logical in H1532 / R1532C8: got 'ATHENS'
## Warning: Expecting logical in H1533 / R1533C8: got 'ATHENS'
## Warning: Expecting logical in H1534 / R1534C8: got 'ATHENS'
## Warning: Expecting logical in H1535 / R1535C8: got 'ORLANDO, FL'
## Warning: Expecting logical in H1536 / R1536C8: got 'SANTANDER'
## Warning: Expecting logical in H1539 / R1539C8: got 'NANTES'
## Warning: Expecting logical in H1548 / R1548C8: got 'ORLANDO, FL'
## Warning: Expecting logical in H1549 / R1549C8: got 'ATHENS'
## Warning: Expecting logical in H1550 / R1550C8: got 'LEMESSOS'
## Warning: Expecting logical in H1551 / R1551C8: got 'LEMESSOS'
## Warning: Expecting logical in H1552 / R1552C8: got 'LEMESSOS'
## Warning: Expecting logical in H1553 / R1553C8: got 'LEMESSOS'
## Warning: Expecting logical in H1556 / R1556C8: got 'FREIBURG'
## Warning: Expecting logical in H1557 / R1557C8: got 'BRISBANE, QLD'
## Warning: Expecting logical in H1558 / R1558C8: got 'SEOUL'
## Warning: Expecting logical in H1559 / R1559C8: got 'ATHENS'
## Warning: Expecting logical in H1560 / R1560C8: got 'SEOUL'
## Warning: Expecting logical in H1562 / R1562C8: got 'LONDON'
## Warning: Expecting logical in H1563 / R1563C8: got 'LONDON'
## Warning: Expecting logical in H1580 / R1580C8: got 'DOULIOU, YUNLIN'
## Warning: Expecting logical in H1581 / R1581C8: got 'MONTREAL, QC'
## Warning: Expecting logical in H1582 / R1582C8: got 'PLZEN'
## Warning: Expecting logical in H1583 / R1583C8: got 'FUNCHAL-MADEIRA'
## Warning: Expecting logical in H1584 / R1584C8: got 'MONTREAL, QC'
## Warning: Expecting logical in H1585 / R1585C8: got 'PITTSBURGH, PA'
## Warning: Expecting logical in H1586 / R1586C8: got 'ATHENS'
## Warning: Expecting logical in H1587 / R1587C8: got 'SAN DIEGO, CA'
## Warning: Expecting logical in H1589 / R1589C8: got 'KYOTO'
## Warning: Expecting logical in H1591 / R1591C8: got 'VIENNA'
## Warning: Expecting logical in H1593 / R1593C8: got 'BARCELONA'
## Warning: Expecting logical in H1594 / R1594C8: got 'CATANIA'
## Warning: Expecting logical in H1595 / R1595C8: got 'ATHENS'
## Warning: Expecting logical in H1597 / R1597C8: got 'PRETORIA'
## Warning: Expecting logical in H1611 / R1611C8: got 'LAS VEGAS, NV'
## Warning: Expecting logical in H1612 / R1612C8: got 'KAOHSIUNG'
## Warning: Expecting logical in H1613 / R1613C8: got 'BORDEAUX'
## Warning: Expecting logical in H1614 / R1614C8: got 'ATHENS'
## Warning: Expecting logical in H1615 / R1615C8: got 'FUNCHAL, MADEIRA'
## Warning: Expecting logical in H1616 / R1616C8: got 'CANCUN'
## Warning: Expecting logical in H1619 / R1619C8: got 'BRISBANE, QLD'
## Warning: Expecting logical in H1629 / R1629C8: got 'HONG KONG'
## Warning: Expecting logical in H1632 / R1632C8: got 'TORONTO, ON'
## Warning: Expecting logical in H1633 / R1633C8: got 'TORONTO, ON'
## Warning: Expecting logical in H1634 / R1634C8: got 'KEYSTONE, CO'
## Warning: Expecting logical in H1635 / R1635C8: got 'NARA'
## Warning: Expecting logical in H1636 / R1636C8: got 'CHONGQING'
## Warning: Expecting logical in H1637 / R1637C8: got 'CHONGQING'
## Warning: Expecting logical in H1639 / R1639C8: got 'SHANGHAI'
## Warning: Expecting logical in H1641 / R1641C8: got 'SAN JOSE, CA'
## Warning: Expecting logical in H1642 / R1642C8: got 'PERUGIA'
## Warning: Expecting logical in H1653 / R1653C8: got 'BEIJING'
## Warning: Expecting logical in H1654 / R1654C8: got 'HONG KONG'
## Warning: Expecting logical in H1658 / R1658C8: got 'HANGZHOU'
## Warning: Expecting logical in H1660 / R1660C8: got 'HANGZHOU'
## Warning: Expecting logical in H1661 / R1661C8: got 'HANGZHOU'
## Warning: Expecting logical in H1663 / R1663C8: got 'LIMASSOL'
## Warning: Expecting logical in H1665 / R1665C8: got 'DALIAN'
## Warning: Expecting logical in H1667 / R1667C8: got 'SAN DIEGO, CA'
## Warning: Expecting logical in H1669 / R1669C8: got 'HANGZHOU'
## Warning: Expecting logical in H1676 / R1676C8: got 'XI'AN'
## Warning: Expecting logical in H1677 / R1677C8: got 'XI'AN'
## Warning: Expecting logical in H1680 / R1680C8: got 'TSUKUBA SCIENCE CITY'
## Warning: Expecting logical in H1681 / R1681C8: got 'PARIS'
## Warning: Expecting logical in H1682 / R1682C8: got 'PARIS'
## Warning: Expecting logical in H1683 / R1683C8: got 'PARIS'
## Warning: Expecting logical in H1684 / R1684C8: got 'BUDAPEST'
## Warning: Expecting logical in H1685 / R1685C8: got 'VIENNA'
## Warning: Expecting logical in H1686 / R1686C8: got 'MELBOURNE, VIC'
## Warning: Expecting logical in H1687 / R1687C8: got 'LAKE TAHOE, NV'
## Warning: Expecting logical in H1690 / R1690C8: got 'SAN JOSE, CA'
## Warning: Expecting logical in H1698 / R1698C8: got 'VANCOUVER'
## Warning: Expecting logical in H1699 / R1699C8: got 'CAVTAT'
## Warning: Expecting logical in H1700 / R1700C8: got 'CAVTAT'
## Warning: Expecting logical in H1703 / R1703C8: got 'CRETE'
## Warning: Expecting logical in H1704 / R1704C8: got 'SUZHOU'
## Warning: Expecting logical in H1705 / R1705C8: got 'TUCSON, AZ'
## Warning: Expecting logical in H1706 / R1706C8: got 'LONDON'
## Warning: Expecting logical in H1707 / R1707C8: got 'BOURNEMOUTH'
## Warning: Expecting logical in H1716 / R1716C8: got 'MONTEREY, CA'
## Warning: Expecting logical in H1717 / R1717C8: got 'MONTEREY, CA'
## Warning: Expecting logical in H1718 / R1718C8: got 'RIO DE JANEIRO'
## Warning: Expecting logical in H1719 / R1719C8: got 'MADEIRA'
## Warning: Expecting logical in H1720 / R1720C8: got 'MUNICH'
## Warning: Expecting logical in H1728 / R1728C8: got 'PORTLAND, OR'
## Warning: Expecting logical in H1730 / R1730C8: got 'ISCHIA'
## Warning: Expecting logical in H1736 / R1736C8: got 'GLYFADA, NR ATHENS'
## Warning: Expecting logical in H1737 / R1737C8: got 'GLYFADA, NR ATHENS'
## Warning: Expecting logical in H1738 / R1738C8: got 'GLYFADA, NR ATHENS'
## Warning: Expecting logical in H1739 / R1739C8: got 'GLYFADA, NR ATHENS'
## Warning: Expecting logical in H1745 / R1745C8: got 'GLYFADA, NR ATHENS'
## Warning: Expecting logical in H1746 / R1746C8: got 'GLYFADA, NR ATHENS'
## Warning: Expecting logical in H1748 / R1748C8: got 'THESSALONIKI'
## Warning: Expecting logical in H1749 / R1749C8: got 'SAN JOSE, CA'
reference_df <- readxl::read_excel(tf,sheet = 4)
journal_df <- readxl::read_excel(tf, sheet = 5)
author_df <- readxl::read_excel(tf, sheet = 6)
TC_all <- readxl::read_excel(tf,sheet = 7)
figure_1_data <- readxl::read_excel(tf, sheet = 8)
table_2_country <- readxl::read_excel(tf, sheet = 10)
figure_2_country_wos_scopus <- readxl::read_excel(tf, sheet = 11)
figure_2_country_wos_scopus_1 <-
readxl::read_excel(tf, sheet = 12) |>
tidygraph::as_tbl_graph(directed = FALSE) |>
activate(nodes) |>
dplyr::mutate(community = tidygraph::group_louvain(),
degree = tidygraph::centrality_degree(),
community = as.factor(community))
table_3_journal <- readxl::read_excel(tf, sheet = 13)
table_4_authors <- readxl::read_excel(tf, sheet = 14)
AU_CO_links <- readxl::read_excel(tf, sheet = 15)
tos <- readxl::read_excel(tf, sheet = 16)
edges_tos <- readxl::read_excel(tf, sheet = 17)
nodes_tos <- readxl::read_excel(tf, sheet = 18)
SO_edges <- readxl::read_excel(tf, sheet = 19)
SO_nodes <- readxl::read_excel(tf, sheet = 20)
AU_ego_edges <- readxl::read_excel(tf, sheet = 21)
AU_ego_nodes <- readxl::read_excel(tf, sheet = 22)
table_1 <-
tibble(wos = length(wos$AU), # Create a dataframe with the values.
scopus = length(scopus$AU),
total = length(wos_scopus$AU))
table_1 %>%
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")))
wos_scopus %>%
tidyr::separate_rows(DT, sep = ";") %>%
dplyr::count(DT, sort = TRUE)%>%
dplyr::mutate(percentage = n /sum(n),
percentage = percentage * 100,
percentage = round(percentage, digits = 2)) %>%
dplyr::rename(total = n) %>%
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")))
Combine charts using Python Matplotlib & Reticulate
library(reticulate)
# create a new environment
# conda_create("r-reticulate")
# install Matplotlib
# conda_install("r-reticulate", "matplotlib")
# import Matplotlib (it will be automatically discovered in "r-reticulate")
plt <- import("matplotlib")
np <- import("numpy")
# From Double get integers
# TC y
TC_all$TC_sum_all <- as.integer(TC_all$TC_sum_all)
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FuncFormatter
# ax=axes
fig, ax = plt.subplots()
# First plot Total Publications - time series
ax.plot(tpx, tpy, color='r',marker='o', label='Total Publications')
ax.set_xlabel('Year')
ax.set_ylabel('Total Publications', color='r')
# Customization for bar charts
barw = 0.5
ax.bar(sx, sy, color='g', label = 'Scopus', alpha = 0.5, width=barw)
## <BarContainer object of 23 artists>
ax.bar(wx1, wy, color='orange', label = 'WoS', alpha=0.8, width=barw)
# Y2 - Total citations
## <BarContainer object of 23 artists>
twin_axes = ax.twinx()
twin_axes.plot(tcx, tcy, color = 'purple',marker='o', label='Total Citations')
twin_axes.set_ylabel('Total Citations', color='purple')
# Customize
plt.title('Total Scientific Production vs. Total Citations')
# y2 Total Citation label location
plt.legend(loc='center left')
# True or False to get the grid at the background
ax.grid(False)
# y1 label location
ax.legend(loc='upper left')
# Y2 limit depends of tcy scale in this case 1400 improves label location
plt.ylim(0, 2500) ######### <-----Important--------- """"Change Y2 Coordinate"""""
# plt.annotate() customize numbers for each position
## (0.0, 2500.0)
for i, label in enumerate(tcy):
plt.annotate(label, (tcx[i], tcy[i] + 0.5), color='purple', size=8)
for i, label in enumerate(tpy):
ax.annotate(label, (tpx[i], tpy[i] + 0.8), color='red', size=8)
for i, label in enumerate(wy):
ax.annotate(label, (wx1[i], wy[i] + 0.1), color='brown', size=8)
for i, label in enumerate(sy):
ax.annotate(label, (sx[i], sy[i] + 0.2),color='green', size=8)
# Rotate x ticks
plt.xticks(tpx)
## ([<matplotlib.axis.XTick object at 0x000001A786B2DF70>, <matplotlib.axis.XTick object at 0x000001A786B2DF40>, <matplotlib.axis.XTick object at 0x000001A786905BB0>, <matplotlib.axis.XTick object at 0x000001A786BB3D00>, <matplotlib.axis.XTick object at 0x000001A786BBC7F0>, <matplotlib.axis.XTick object at 0x000001A786BC02E0>, <matplotlib.axis.XTick object at 0x000001A786BB3550>, <matplotlib.axis.XTick object at 0x000001A786BC0FD0>, <matplotlib.axis.XTick object at 0x000001A786BC7AC0>, <matplotlib.axis.XTick object at 0x000001A786BCC5B0>, <matplotlib.axis.XTick object at 0x000001A786BCCE20>, <matplotlib.axis.XTick object at 0x000001A786BC73A0>, <matplotlib.axis.XTick object at 0x000001A786BD3910>, <matplotlib.axis.XTick object at 0x000001A786BD9400>, <matplotlib.axis.XTick object at 0x000001A786BD9EB0>, <matplotlib.axis.XTick object at 0x000001A786BDF9A0>, <matplotlib.axis.XTick object at 0x000001A786BC7D30>, <matplotlib.axis.XTick object at 0x000001A786BDFEB0>, <matplotlib.axis.XTick object at 0x000001A786BE8BE0>, <matplotlib.axis.XTick object at 0x000001A786BEC6D0>, <matplotlib.axis.XTick object at 0x000001A786BECF40>, <matplotlib.axis.XTick object at 0x000001A786BE84C0>, <matplotlib.axis.XTick object at 0x000001A786BF3910>], [Text(2022.0, 0, '2022'), Text(2021.0, 0, '2021'), Text(2020.0, 0, '2020'), Text(2019.0, 0, '2019'), Text(2018.0, 0, '2018'), Text(2017.0, 0, '2017'), Text(2016.0, 0, '2016'), Text(2015.0, 0, '2015'), Text(2014.0, 0, '2014'), Text(2013.0, 0, '2013'), Text(2012.0, 0, '2012'), Text(2011.0, 0, '2011'), Text(2010.0, 0, '2010'), Text(2009.0, 0, '2009'), Text(2008.0, 0, '2008'), Text(2007.0, 0, '2007'), Text(2006.0, 0, '2006'), Text(2005.0, 0, '2005'), Text(2004.0, 0, '2004'), Text(2003.0, 0, '2003'), Text(2002.0, 0, '2002'), Text(2001.0, 0, '2001'), Text(2000.0, 0, '2000')])
fig.autofmt_xdate(rotation = 70)
# The Y1 ticks depends from tpy scale limits
yticks = [0,30,60,90,120,150,180,210,240,270] ########## <-----Important---- Choose scale .. just specify which numbers you want
ax.set_yticks(yticks)
# Export Figure as SVG
plt.savefig("Unad4.svg")
plt.show()
table_2_country |>
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")))
figure_2a <-
figure_2_country_wos_scopus_1 |>
activate(edges) |>
# tidygraph::rename(weight = n) |>
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_2a
figure_2b <-
figure_2_country_wos_scopus_1 |>
activate(nodes) |>
data.frame() |>
group_by(community) |>
dplyr::count(community, sort = TRUE) |>
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 = "Countries") +
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_2b
# Create a dataframe with links
figure_2c_edges <-
figure_2_country_wos_scopus |>
dplyr::filter(from != to) |>
tidygraph::as_tbl_graph() |>
activate(edges) |>
as_tibble() |>
dplyr::select(year = PY) |>
dplyr::count(year) |>
dplyr::filter(year >= 2002,
year <= 2022) |>
dplyr::mutate(percentage = n/max(n)) |>
dplyr::select(year, percentage)
# Create a data frame with author and year
figure_2c_nodes <- # 21 row
figure_2_country_wos_scopus |>
dplyr::filter(from != to) |>
tidygraph::as_tbl_graph() |>
activate(edges) |>
as_tibble() |>
dplyr::select(CO = from,
year = PY) |>
bind_rows(figure_2_country_wos_scopus |>
tidygraph::as_tbl_graph() |>
tidygraph::activate(edges) |>
tidygraph::as_tibble() |>
dplyr::select(CO = to,
year = PY)) |>
unique() |>
dplyr::group_by(CO) |>
dplyr::slice(which.min(year)) |>
dplyr::ungroup() |>
dplyr::select(year) |>
dplyr::group_by(year) |>
dplyr::count(year) |>
dplyr::filter(year >= 2002,
year <= 2022) |>
dplyr::ungroup() |>
dplyr::mutate(percentage = n / max(n)) |>
select(year, percentage)
figure_2c <-
figure_2c_nodes |>
mutate(type = "nodes",
year = as.numeric(year)) |>
bind_rows(figure_2c_edges |>
mutate(type = "links",
year = as.numeric(year))) |>
ggplot(aes(x = year,
y = percentage,
color = type)) +
geom_point() +
geom_line() +
theme(legend.position = "right",
text = element_text(color = "black",
face = "bold",
family = "Times"),
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",
angle = 45, vjust = 0.5
),
axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20),
legend.text = element_text(size = "15"),
legend.title = element_blank()) +
labs(title = "Nodes and links through time",
y = "Percentage") +
scale_y_continuous(labels = scales::percent) +
scale_x_continuous(breaks = seq(2002, 2022, by = 1))
figure_2c
table_3_journal |>
arrange(desc(total)) |>
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)
Selecting nodes to show
figure_3a_1 <-
SO_edges %>%
tidygraph::as_tbl_graph() %>%
tidygraph::activate(nodes) %>%
# tidygraph::mutate(id = name) %>%
tidygraph::left_join(SO_nodes, by = c("name" = "id")) %>%
tidygraph::select(-name) %>%
tidygraph::rename(name = Label) %>%
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_1
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"),
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
# Create a dataframe with links
figure_3c_edges <-
journal_df |>
select(from = JI_main, to = JI_ref, PY = PY_ref) %>%
dplyr::filter(from != to) |>
tidygraph::as_tbl_graph() |>
activate(edges) |>
as_tibble() |>
dplyr::select(year = PY) |>
dplyr::count(year) |>
dplyr::filter(year >= 2002,
year <= 2022) |>
dplyr::mutate(percentage = n/max(n)) |>
dplyr::select(year, percentage)
# Create a data frame with author and year
figure_3c_nodes <- # 21 row
journal_df |>
select(from = JI_main, to = JI_ref, PY = PY_ref) %>%
dplyr::filter(from != to) |>
tidygraph::as_tbl_graph() |>
activate(edges) |>
as_tibble() |>
dplyr::select(CO = from,
year = PY) |>
bind_rows(journal_df |>
select(from = JI_main,
to = JI_ref,
PY = PY_ref) %>%
tidygraph::as_tbl_graph() |>
tidygraph::activate(edges) |>
tidygraph::as_tibble() |>
dplyr::select(CO = to,
year = PY)) |>
unique() |>
dplyr::group_by(CO) |>
dplyr::slice(which.min(year)) |>
dplyr::ungroup() |>
dplyr::select(year) |>
dplyr::group_by(year) |>
dplyr::count(year) |>
dplyr::filter(year >= 2002,
year <= 2022) |>
dplyr::ungroup() |>
dplyr::mutate(percentage = n / max(n)) |>
select(year, percentage)
plotting figure 3b
figure_3c <-
figure_3c_nodes |>
mutate(type = "nodes") |>
bind_rows(figure_3c_edges |>
mutate(type = "links")) |>
ggplot(aes(x = year,
y = percentage,
color = type)) +
geom_point() +
geom_line() +
theme(legend.position = "right",
text = element_text(color = "black",
face = "bold",
family = "Times"),
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",
angle = 45, vjust = 0.5
),
axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20),
legend.text = element_text(size = "15"),
legend.title = element_blank()) +
labs(title = "Nodes and links through time",
y = "Percentage") +
scale_y_continuous(labels = scales::percent) +
scale_x_continuous(breaks = seq(2002, 2022, by = 1))
figure_3c
tos %>%
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")))