2016-01-19 62 views
0

为什么我的地块没有写入磁盘有什么原因吗?我按照this description保存我的地块,但它不起作用。每个情节只是一个白色的图像。为什么?为什么我的绘图不能写入磁盘?

这是我正在使用的完整脚本;

library(rAltmetric) 
library(aRxiv) 

print('Load DOIs ..') 

doi_list <- list() 

categ <- c(AP = 'cat:stat.AP', 
      CO = "cat:stat.CO", # I'm naming these elements so 
      ME = "cat:stat.ME", # that the corresponding elements 
      TH = "cat:stat.TH", # in the list are named as well. 
      ML = "cat:stat.ML") # Could also just set 'names(doi_list)' to 'categ'. 

doi_list <- 
    lapply(categ, function(ctg) 
    (doi <- arxiv_search(ctg)$doi)[nchar(doi) > 0]) 

print('Showing altmetrics ..') 

num = 0 

for(category in doi_list) { 

    for(mydoi in category) { 
    print(paste('Searching DOI:', mydoi)) 

    #acuna <- altmetrics(doi=mydoi) 
    acuna <- altmetrics(doi="10.1038/489201a") 

    if(is.null(acuna)) { 
     next 
    } 

    print(acuna) 

    acuna_data <- altmetric_data(acuna) 
    jpeg(filename=paste(num, ".jpg", sep="")) 
    plot(acuna, main=paste(num, ".jpg", sep="")) 
    dev.off() 
    num <- num + 1 
    } 
} 

print('All done.') 
+0

如果是喜欢xyplot,您可以尝试这个http://stackoverflow.com/questions/13114594/problems-saving-several-pdf-files-in-r – user1436187

回答

0

我敢肯定这是R FAQ 7.22

7.22为什么格/网格显卡无法正常工作?

最可能的原因是你忘记告诉R显示图形。格子函数(如xyplot())创建图形对象,但不显示它(ggplot2图形和S-PLUS中的格子图形也是如此)。图表对象的print()方法会生成实际的显示。当您在命令行中交互使用这些函数时,结果会自动打印,但在source()或您自己的函数中,您将需要明确的print()声明。

使用

print(plot(acuna, main=paste(num, ".jpg", sep=""))) 
+0

是的,这作品。谢谢! :) – displayname

相关问题