-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathR_GoogleCitationsPlotly.R
More file actions
62 lines (48 loc) · 1.89 KB
/
Copy pathR_GoogleCitationsPlotly.R
File metadata and controls
62 lines (48 loc) · 1.89 KB
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
## Griffiths M (2024) Citation plot from Google Scholar profile using R and plotly
################
## User setup ## ---------------------------------------------------------------
################
library("scholar")
library("plotly")
library("tidyverse")
library("scales")
##############################
## Define scholar dataframe ## -------------------------------------------------
##############################
# Find and replace the google scholar id part of profile URL -------------------
id <- "X--dqYYAAAAJ&hl=en&oi=ao"
scholar <- get_profile(id)
scholar$name
scholar$affiliation
scholar$h_index
scholar$i10_index
## create citation_history dataframe -------------------------------------------
citation_history <- get_citation_history(id)
citation_history
#####################################
## Plot figure with scholar data ## --------------------------------------------
#####################################
# Plot barchart citations per year ---------------------------------------------
p <- ggplot(data=citation_history, aes(x=year, y=cites)) +
geom_bar(stat="identity") +
theme_bw() +
theme(
plot.background = element_blank()
,panel.grid.major = element_blank()
,panel.grid.minor = element_blank()
) +
xlab(bquote("Year")) +
ylab(bquote("Citations")) +
# scale_x_continuous(breaks = 2016:2024)
# scale_x_continuous(labels = scales::number_format(accuracy = 1))
scale_x_continuous(breaks = scales::breaks_width(2))
p <- ggplotly(p)
p
###########################
## Upload plot to plotly ## ----------------------------------------------------
###########################
# Replace USERNAME and APIKEY with your plotly details -------------------------
Sys.setenv("plotly_username"="mdgriffiths")
Sys.setenv("plotly_api_key"="7ILBBxStrQOBjjb19Vs0")
# Upload plot to plotly --------------------------------------------------------
api_create(p, filename = "googlecitations")