-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_data_impact.R
88 lines (70 loc) · 2.57 KB
/
make_data_impact.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
# ------------------------------
# Scholar data
# ------------------------------
library(dplyr)
library(scholar)
library(ggplot2)
library(forcats)
library(patchwork)
library(see)
data_scholar <- list()
data_scholar[["date"]] <- format(Sys.time(), "%d %B %Y")
data_scholar[["scholar_stats"]] <- scholar::get_profile("bg0BZ-QAAAAJ")
data_scholar[["scholar_history"]] <- scholar::get_citation_history("bg0BZ-QAAAAJ")
data_scholar[["scholar_publications"]] <- scholar::get_publications("bg0BZ-QAAAAJ", flush = TRUE) |>
mutate(author = scholar::get_complete_authors("bg0BZ-QAAAAJ", pubid))
data_scholar[["scholar_data"]] <- data_scholar[["scholar_publications"]] %>%
dplyr::filter(year > 1950) %>%
dplyr::group_by(year) %>%
dplyr::summarise(
Publications = n(),
# Citations = sum(cites)
) %>%
dplyr::mutate(
Publications = cumsum(Publications)
# Citations = cumsum(Citations)
) %>%
dplyr::rename(Year = year) %>%
tidyr::gather(Index, Number, -Year) %>%
dplyr::mutate(Index = forcats::fct_rev(Index)) %>%
rbind(data_scholar[["scholar_history"]] %>%
dplyr::rename(Number = cites,
Year = year) %>%
mutate(Index = "Citations",
Number = cumsum(Number)))
# Publications individual
data <- data_scholar[["scholar_publications"]] %>%
mutate(Authors = paste0(lapply(stringr::str_split(author, " "), `[[`, 2)),
Authors = stringr::str_to_title(stringr::str_remove_all(Authors, ",")),
Publication = paste0(Authors, " (", year),
Journal = stringr::str_to_title(journal))
# Disambiguate unique
suffix <- letters
suffix[1] <- ""
for(i in 1:nrow(data)){
pub <- data$Publication[i]
j <- 1
while(paste0(pub, suffix[j]) %in% data$Publication[1:i-1]){
j <- j + 1
}
data$Publication[i] <- paste0(pub, suffix[j])
}
data_scholar[["scholar_publications"]] <- data %>%
mutate(Publication = paste0(Publication, ")"),
Publication = fct_reorder(Publication, cites, .desc = TRUE)) %>%
filter(Publication != "Makowski (2013)")
save(data_scholar, file="data/data_scholar.Rdata")
# p2 <- data_scholar$scholar_publications %>%
# ggplot(aes(x = cites)) +
# geom_histogram(bins = 30) +
# geom_density(aes(y = 3 * stat(count)), bw="SJ") +
# see::theme_modern() +
# theme(
# strip.background = element_blank(),
# axis.title = element_text(face = "plain", size = 16),
# legend.position = "none"
# )
# p2
# p1 / p2
# ggsave(paste0(path, "img/plot_impact.png"), p1, dpi=450, width=10, height=8)
# ggsave(paste0(path, "img/plot_citations.png"), p2, dpi=450, width=10, height=4)