SCI写作rice related analysisSCI写作指南

如何获取本领域科研发表文章的趋势图-pubmed

2019-03-23  本文已影响55人  Dayueban

首先需要安装一些软件包

yyplot包是存放于github里的一个R软件包,因为不是存放于标准R库,如CRANbioconductor里,所以需要通过devtools包里的install_github()函数下载

install.packages("ggimage")
install.packages("qrcode")
library(devtools)
install_github("GuangchuangYu/yyplot")

报错如下

# Downloading GitHub repo #GuangchuangYu/yyplot@master
# Error in utils::download.file(url, path, method #= download_method(), quiet = quiet,  : 
# cannot open URL 
# https://api.github.com/repos/GuangchuangYu/yyplot/tarball/master

于是,就是一通搜索解决install github方式下载包出错的方法,其实之前就碰到过了,一致没解决,于是今天就把找到的一个解决办法分享在这里,让更多的人知道

image image

下面直接给出获取本领域发表文章趋势作图代码

##The script to abtain the trend of metagenomic##
rm(list = ls())
panel_title <- "The trend of gut microbiota and metabolomics"
sub_title <- "Source: https://www.ncbi.nlm.nih.gov/pubmed/"
term <- c("metagenomic","gut microbiota")
year <- 2010:2018
​
library(yyplot)
library(ggplot2)
library(ggrepel)
pm <- pubmed_trend(term,year = year)
colnames(pm)[1] <- "Year" # 修改列名
colnames(pm)[3] <- "Articles"
​
ggplot(pm,mapping = aes(x = Year,y = Articles)) +
 geom_point(aes(colour=TERM)) + geom_smooth(aes(colour=TERM)) + theme_bw() + 
 ggtitle(panel_title, subtitle = sub_title)+
 geom_label_repel(aes(label= Articles)) +
 theme(
 plot.title = element_text(hjust = 0.5),
 axis.title.x = element_text(size = 16),
 axis.title.y = element_text(size = 16),
 axis.text.x = element_text(size = 12, colour = "grey50"),
 axis.text.y = element_text(size = 12, colour = "grey50"),
 legend.title = element_text(size=14),
 legend.text = element_text(size = 12),
 legend.key.size = unit(0.8,"cm")
 )
ggsave("metagenomic_pubmed_trend.tiff",width = 10,height = 8)
文章发表趋势图

参考

[1] https://ask.csdn.net/questions/713186 install github出错解决方法

上一篇下一篇

猜你喜欢

热点阅读