Getting R Publication Trendline
Sometimes you like to get the publication trend for the research topic you are working on. I compiled some of the codes that may be helpful to get that trendline. The code is not perfect yet but should be good for including such graphs in your presentations.
library(devtools)
#install_github("ropensci/rentrez")
library(rentrez)
#getting data
papers_by_year <- function(years, search_term){
return(sapply(years, function(y) entrez_search(db="pubmed",term=search_term, mindate=y, maxdate=y, retmax=0)$count))
}
years <- 1980:2018
total_papers <- papers_by_year(years, "")
omics <- c("Seneca Valley Virus")
trend_data <- sapply(omics, function(t) papers_by_year(years, t))
#converting into data frame
mytable<-data.frame(trend_data,years)
# Change barplot fill colors by groups
library(ggplot2)
attach(mytable)
## The following object is masked _by_ .GlobalEnv:
##
## years
p<-ggplot(mytable, aes(x=years, y=Seneca.Valley.Virus,fill=Seneca.Valley.Virus)) +
geom_bar(stat="identity")+theme_minimal()
p+labs(x="Year",y= "No.of Publications", title= "Senecavirus A Publication Trend",
caption="(based on NCBI database using rentrez package in R studio)")

That’s it. Now you can use the searchterm you like and get similar plots.