Step 1: Navigate to PubMed

Navigate to PubMed and enter your search term(s) (e.g., “pupillometry”)

Enter your search terms(s) as you normally would

Step 2: Specify data range

Specify year range and export the CSV Use the sliders or manually specify a range

Step 3: Export the data (csv)

Clean up the CSV a bit either here or offline. PubMed appends a useless row at the top that R will think is a header. I deleted the top row and changed the filename to ‘pupil.csv’ and moved the file into my data directory in this project Download the csv file

Step 4: Read data and inspect

pup <- read.csv(here("data", "pupil.csv"), header = T) %>% data.frame()
head(pup)  #looks like you need to sort ascending on year
Year Count
2021 172
2020 230
2019 190
2018 171
2017 122
2016 115
str(pup)
## 'data.frame':    52 obs. of  2 variables:
##  $ Year : int  2021 2020 2019 2018 2017 2016 2015 2014 2013 2012 ...
##  $ Count: int  172 230 190 171 122 115 96 73 48 40 ...
pupsort <- pup[order(pup$Year), ]
head(pupsort)
Year Count
52 1961 1
51 1963 2
50 1969 2
49 1971 1
48 1972 1
47 1973 1


Step 5: Plot it!

Then save it to a PDF

countplot <- ggplot(pupsort, aes(x = Year, y = Count)) + geom_point(color = "seagreen4", 
    shape = 17, size = 2) + xlab("Year") + ylab("Citation Count") + jamie.theme + 
    ggtitle("Annual Citation Count for Pupillometry Since 1960") + scale_x_continuous(breaks = seq(1945, 
    2020, by = 5)) + scale_y_continuous(breaks = seq(0, 2020, by = 25))
polyplot <- countplot + geom_smooth(method = "lm", formula = y ~ poly(x, 5), se = FALSE, 
    color = "gray")
print(polyplot)

ggsave("polyplot.pdf", polyplot)