在批处理模式下运行R问题

时间:2016-09-15 22:44:20

标签: r

在过去的几天里,我一直在努力完成Norman Matloff的 R编程艺术。本书的第一个例子如下:

# test.R 
# Creates a histogram of 100 normal variates and saves it to xh.pdf.
pdf("xh.pdf")
hist(rnorm(100))
dev.off()

作者说执行$ R CMD BATCH test.R会生成 xh.pdf ,但这并不起作用。我用google搜索&#34; R批处理模式&#34;并设法使用$ R --no-save < test.R生成PDF文件。任何人都知道为什么第二种方法有效,但第一种方法没有?

更多信息:我在OSX El Capitan上。 $ R CMD BATCH test.R生成一个文件 test.Rout ,其中包含以下内容:

/usr/local/Cellar/r/3.3.0/R.framework/Resources/bin/R: line 201:
/usr/local/Library/ENV/4.3/sed: No such file or directory

1 个答案:

答案 0 :(得分:1)

我按照here列出的步骤解决了这个问题。

  
      
  1. 将其符号链接到我的自制文件夹ln -s / opt / X11 / include / X11   / usr / local / include / X11(请注意您的自制程序目录可能是   不同)
  2.   
  3. brew install homebrew / dupes / tcl-tk
  4.   
  5. brew链接 - 覆盖   --force tcl-tk; brew unlink tcl-tk brew重新安装-s r
  6.