我对R包学者有疑问
什么有效:
get_citation_history(SSalzberg)
Run Code Online (Sandbox Code Playgroud)
什么不:
get_article_cite_history(SSalzberg, "any article")
Run Code Online (Sandbox Code Playgroud)
代码:
article <- "Ultrafast and memory-efficient alignment of short DNA sequences to the human genome"
SSalzberg <- "sUVeH-4AAAAJ" (Google Scholar ID)
get_article_cite_history(SSalzberg, article)
Run Code Online (Sandbox Code Playgroud)
错误信息:
Error in min(years):max(years) : result would be too long a vector
In addition: Warning messages:
1: In min(years) : no non-missing arguments to min; returning Inf
2: In max(years) : no non-missing arguments to max; returning -Inf
Run Code Online (Sandbox Code Playgroud)
我不理解该函数上下文中的错误消息,我尝试了另一篇文章与另一位作者没有成功.我不知道我在这里失踪了什么....谢谢
您必须使用文章ID,而不是文章的标题.可能最简单的方法是检索完整的pubs列表,其中包含一pubid列...
library(scholar)
SSalzberg <- "sUVeH-4AAAAJ"
all_pubs <- get_publications(SSalzberg)
## next step is cosmetic -- the equivalent of stringsAsFactors=FALSE
all_pubs <- as.data.frame(lapply(all_pubs,
function(x) if (is.factor(x)) as.character(x) else x))
w <-grep("Ultrafast",all_pubs$title) ## publication number 3
all_pubs$title[w]
## [1] Ultrafast and memory-efficient alignment of ...
all_pubs$pubid[w] ## "Tyk-4Ss8FVUC"
ch <- get_article_cite_history(SSalzberg,all_pubs$pubid[w])
plot(cites~year,ch,type="b")
Run Code Online (Sandbox Code Playgroud)