library(RISmed)
##限定下检索主题
search_topic <- c('DNA methylation in plant')
search_query <- EUtilsSummary(search_topic,db="pubmed", retmax=10000,datetype='pdat', mindate=2000, maxdate=2018)
##查查看下检索内容
summary(search_query)
##看下这些文献的Id
QueryId(search_query)
##获取检索结果
records<- EUtilsGet(search_query)
class(records)
str(records)
##提取检索结果
pubmed_data <- data.frame('Title'=ArticleTitle(records),
'Year'=YearAccepted(records),
'journal'=ISOAbbreviation(records))
head(pubmed_data,1)
pubmed_data[1:3,1]
write.csv(pubmed_data,file='DNA_methylation_in_plant.csv')
##分析文章情况
y <- YearPubmed(EUtilsGet(search_query))
##可视化一下
library(ggplot2)
date()
count <- table(y)
count <- as.data.frame(count)
names(count)<-c("Year", "Counts")
library(ggsci)
ggplot(data=count, aes(x=Year, y=Counts,fill=Year)) +
geom_bar(stat="identity", width=0.5)+
labs(y = "Number of articles",title="PubMed articles containing DNA methylation in plant"
) + theme_bw() + scale_fill_manual(values = colorRampPalette(brewer.pal(19, "Accent"))(19)) +
theme(legend.position="bottom")