Skip to content

Instantly share code, notes, and snippets.

@kumeS
Created June 24, 2020 18:54
Show Gist options
  • Save kumeS/a9e612c6bb484451e6328f119fd9ef56 to your computer and use it in GitHub Desktop.
Save kumeS/a9e612c6bb484451e6328f119fd9ef56 to your computer and use it in GitHub Desktop.
Number of PubMed articles containing the keyword.
if(!require("RISmed")){install.packages("RISmed")}; library(RISmed)
if(!require("magrittr")){install.packages("magrittr")}; library(magrittr)
if(!require("purrr")){install.packages("purrr")}; library(purrr)
if(!require("plotly")){install.packages("plotly")}; library(plotly)
if(!require("progress")){install.packages("progress")}; library(progress)
PublicationPerYear <- function(Term="Coronavirus"){
PubNumber <- c()
TERM <- Term
x <- 1
Years <- 1970:2020
pb <- progress_bar$new(format = " Process [:bar] :percent eta: :eta",
total = length(Years), clear = FALSE, width= 50)
for (i in Years){
r <- EUtilsSummary(TERM, type='esearch', db='pubmed', mindate=i, maxdate=i)
PubNumber[x] <- QueryCount(r)
x <- x + 1
pb$tick()
}
Data <- data.frame(Years, PubNumber)
library(plotly)
fig <- plot_ly(Data, x = ~Years, y = ~PubNumber, type = 'bar', name = 'Publications',
marker = list(color = 'rgb(158,202,225)', line = list(color = 'rgb(8,48,107)', width = 1)))
fig <- fig %>% layout(title = paste("Number of PubMed articles containing ", TERM, sep=""),
yaxis = list(title = 'Count'),
xaxis = list(title = "Year"))
return(fig)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment