Skip to content

Instantly share code, notes, and snippets.

@jebyrnes
Last active November 1, 2024 18:00
Show Gist options
  • Save jebyrnes/b1f57a85cfd9a0ebe4d0a16c2e2a8ab4 to your computer and use it in GitHub Desktop.
Save jebyrnes/b1f57a85cfd9a0ebe4d0a16c2e2a8ab4 to your computer and use it in GitHub Desktop.
Get your coauthors for the last 4 years, nsf-style
library(scholar)
library(dplyr)
library(purrr)
library(tidyr)
id <- "hJKBuhkAAAAJ"
#me <- get_profile(id)
pubs <- get_publications(id) %>% as_tibble
auth_out <- function(auth_vec){
strsplit(auth_vec, ", ")[[1]] %>%
gsub("(.*) (.*)", "\\2, \\1", .)
}
auth_out_2 <- function(id, pubid){
auth_vec <- get_complete_authors(id = id, pubid = pubid)
strsplit(auth_vec, ", ")[[1]] %>%
gsub("(.*) (.*)$", "\\2, \\1", .)
}
coauthors <- map2_df(pubs$year, pubs$pubid,
~tibble(year = .x, author = auth_out_2(id, .y)))
coauthors_filter_unique <- coauthors %>%
filter(author != "...") %>%
group_by(author) %>%
arrange(year) %>%
slice(1L) %>%
ungroup()
coauthors_filter_unique %>%
filter(year>=2016) %>%
arrange(author)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment