Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active September 30, 2021 00:19
Show Gist options
  • Save juanchiem/0564a741fd21d8a4651d5440cebfc791 to your computer and use it in GitHub Desktop.
Save juanchiem/0564a741fd21d8a4651d5440cebfc791 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(scholar)
# get from scholar profile urlafter "/citations?user=" and before "=en"
id_authorname <- "TQQzkCwAAAAJ&hl"
profile_authorname <- get_profile(id_authorname)
profile_authorname
library(googlesheets4)
gs4_auth(email = "author_email@...")
papers_sheet <- gs4_create("peer_review_authorname") # ONLY ONCE!
papers_sheet %>% gs4_browse()
papers_authorname <- get_publications(id_authorname, sortby = "citation")
impact <- get_journalrank(journals=papers_authorname$journal)
papers_authorname <- cbind(papers_authorname, impact)
dim(papers_authorname)
papers_authorname %>%
filter(Type=="journal") %>%
mutate(rank = row_number(),
years = if_else(lubridate::year(Sys.Date())-year == 0, 1, lubridate::year(Sys.Date())-year),
cites_per_year=round(cites/years,2)) %>%
dplyr::select(rank, year, title, journal, cites, cites_per_year, Country, SJR, SJR.Best.Quartile, author) -> peer_reviewed_authorname
peer_reviewed_authorname %>%
sheet_write(ss=papers_sheet, sheet="published")
peer_reviewed_authorname %>%
group_by(journal) %>%
summarise(n=n(),
Q=first(SJR.Best.Quartile)) %>%
arrange(-n) %>%
sheet_write(ss=papers_sheet, sheet="per_journal")
peer_reviewed_authorname %>%
count(SJR.Best.Quartile, sort=T) %>%
sheet_write(ss=papers_sheet, sheet="per_Q")
# citation evolution
citation_history <- get_citation_history(id_authorname)
p1 <- citation_history %>%
ggplot()+
aes(x=year, y=cites)+
geom_line(col="blue") +
geom_dotplot(data=peer_reviewed_authorname %>%
count(year) %>%
uncount(n) %>%
mutate(y=1),
aes(year, y=y),
fill = "orange", color = "black", show.legend=T,
method = 'histodot', binwidth = 1, dotsize=.1) +
scale_x_continuous(breaks = min(citation_history):max(citation_history))+
labs(x="", title="Publications (dots)\nCitations per year (line) ")
p1
# Coauthors network
p2 <- get_coauthors(id_authorname) %>%
plot_coauthors(size_labels=3) +
ggtitle(paste0(profile_authorname$name, " coauthorship's network"))
p2
library(patchwork)
p1 | p2
@juanchiem
Copy link
Author

juanchiem commented Sep 29, 2021

plot_juan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment