R and d3.js code for detecting citation growth patterns.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Sleeping Beauties

This R and javascript code reads a citation report from Web of Science that has been manually processed (header removed, graphs removed) and creates d3.js graph intended to show "sleeping beauties," articles that go a relatively long time before starting to accumulate citations.

For more detail, see this post and Kieran Healy's post.


Create a citation report from journals of interest in web of science. Save the top 500 results or so as a text file. Open the text file (usually named "savedrecs.txt") and delete the header. Save it as "journal.csv" or similar in the sb directory.

From R, evaluate the write_sleeping_beauty and plotgraph functions.

sb <- write_sleeping_beauty("citations.csv", 20)

will return a dataframe that can be passed to plotgraph. It will also save a file named "data.csv" Open the sb.html file in your browser to see the d3.js visualization.

To make a plot from R, use:

gg <- plotgraph(sb,1,10)

This will return a ggplot object that highlights articles that went ten years with no citations. Adjust parameters to suit.

See here, here, here, here, and here for examples.


The d3.js visualization is based on this example by Mike Bostock. Lynn Cherny's code helped me understand how to adapt the original example and was helpfully commented. This stackoverflow question and answer was also helpful.

I also got valuable feedback from a conversation with PJ Trainor, Nabil Kashyap, and Rachel Buurma.


  1. Automate read procedure so that it doesn't require manual spreadsheet tweaking. Still have to delete small header.
  2. Regularize capitalization of titles.
  3. Clean and indent js code properly.