服务热线
178 0020 3020
library("httr") yeardata=c() countdata=c() url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi" for (i in 1:10) { year=2007 +i term = paste('miRNA[TI] AND ',year,'[DP]',sep = "") r<- POST( url, body = list( db='pubmed', term=term, retmode='json', retstart=0, retmax=10, rettype='uilist' ) ) stop_for_status(r) data=content(r,"parsed","application/json") esearchresult=data$esearchresult count=esearchresult$count yeardata=c(yeardata,year) countdata=c(countdata,count) } data=data.frame(year=yeardata,count=countdata) print(data) library(ggplot2) ggplot(data,aes(x=factor(year),y=count))+ geom_bar(aes(fill=count),stat = "identity")+ geom_text(label=data$count,colur='red',vjust=-0.5)+ theme(axis.ticks = element_blank(), panel.grid.minor.y=element_blank(), panel.grid.major.y = element_blank(), axis.text.y =element_blank())+ labs(x='year',y='count')
附件