-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.R
85 lines (75 loc) · 2.76 KB
/
functions.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
library(dplyr)
library(ggplot2)
# Get dataframe with stats
get_stats <- function(data_scholar) {
# Author position
authors <- tolower(data_scholar$scholar_publications$author)
authors <- strsplit(authors, ", ")
position <- sapply(authors, function(x) {
position <- which(x == "d makowski")
if(position == 1) return("First")
if(position == 2) return("Second")
if(position == length(x)) return("Last")
"Other"
})
position <- as.data.frame(t(as.matrix(table(position))))
# Manual corrections --------------------
# Nicolas & Makowski 2016
position$Last <- position$Last - 1 #
position$Second <- position$Second + 1
# Sperduti & Makowski 2017 (fiction 2)
position$First <- position$First + 1 #
position$Second <- position$Second - 1
# Stats
data.frame(
"n.Publications" = length(authors),
"n.FirstAuthor" = position$First,
"n.SecondAuthor" = position$Second,
"n.LastAuthor" = position$Last,
"H.index" = data_scholar$scholar_stats$h_index,
"Citations" = data_scholar$scholar_stats$total_cites
)
}
# Make plot with number of publications and number of citations
plot_impact <- function(data_scholar) {
data <- data_scholar$scholar_data
data |>
dplyr::filter(Year >= 2014) |>
ggplot(aes(x = Year, y = Number)) +
geom_bar(aes(alpha=Year), stat="identity") +
geom_line(aes(colour = Index), linewidth = 2) +
see::theme_modern() +
ylab("") +
scale_x_continuous(labels = paste0("'", substr(data$Year, 3, 4)),
breaks = data$Year) +
# scale_x_continuous(breaks = seq(min(stats$Year), max(stats$Year), by = 1)) +
scale_color_manual(values = c("#2196F3", "#E91E63")) +
facet_wrap(~Index, scales = "free", strip.position = "top") +
theme(
strip.background = element_blank(),
strip.placement = "outside",
# strip.text.y = element_blank(),
strip.text = element_text(face = "plain", size = 16),
axis.title = element_text(face = "plain", size = 16),
axis.title.x = element_blank(),
legend.position = "none"
)
}
# Make plot with number of publications and number of citations
plot_citations_per_paper <- function(data_scholar) {
data <- data_scholar$scholar_data
data_scholar[["scholar_publications"]] |>
ggplot(aes(x = Publication, y = cites, label = Journal)) +
geom_bar(aes(fill=Publication), stat="identity") +
# geom_text(angle=90, y=1, hjust = 0) +
see::theme_modern() +
scale_fill_material_d(palette="rainbow", reverse=TRUE) +
ylab("Number of citations") +
scale_y_continuous(expand = c(0, 0), limits = c(0, NA)) +
theme(
# axis.title = element_text(face = "plain"),
axis.title.x = element_blank(),
axis.text.x = element_text(angle=45, hjust=1),
legend.position = "none"
)
}