Skip to content

Instantly share code, notes, and snippets.

@mcfrank
Created January 25, 2018 22:58
Show Gist options
  • Select an option

  • Save mcfrank/3119a76fda7f54817eee17c7e9f5e8f2 to your computer and use it in GitHub Desktop.

Select an option

Save mcfrank/3119a76fda7f54817eee17c7e9f5e8f2 to your computer and use it in GitHub Desktop.
psych sci author network
library(tidyverse)
library(viridis)
library(knitr)
d <- read_csv("AuthorList.csv")
authors <- d %>%
group_by(author) %>%
count
d %>%
group_by(year) %>%
summarise(n_papers = length(unique(article_id)),
n_authors = length(author),
n_authors_per_paper = n_authors / n_papers,
n_unique_authors = length(unique(author))) %>%
kable(digits = 2)
unique_authors <- d %>%
select(-article_id) %>%
distinct
overlaps <- d %>%
split(.$year) %>%
map_df(function(x) {
this_year_authors = unique(x$author)
overlap <- unique_authors %>%
group_by(year) %>%
summarise(overlap = sum(author %in% this_year_authors),
dice = (2 * overlap) / (length(author) + length(this_year_authors))) %>%
mutate(source_year = x$year[1])
}) %>%
mutate(overlap = ifelse(year == source_year, NA, overlap),
dice = ifelse(year == source_year, NA, dice))
ggplot(filter(overlaps, year > 2008 & year < 2018,
source_year > 2008 & source_year < 2018),
aes(x = year, y = source_year, fill = dice)) +
geom_tile() +
xlim(2009,2018) +
scale_fill_viridis() +
theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment