0

I've been working through The Art of R Programming by Norman Matloff for the past couple of days. One of the first examples in the book is the following:

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

The author says executing $ R CMD BATCH test.R would generate xh.pdf, but that didn't work. I googled "R batch mode" and managed to generate the PDF file using $ R --no-save < test.R. Anyone know why the second method works but the first doesn't?

More Info: I'm on OSX El Capitan. $ R CMD BATCH test.R produces a file, test.Rout, that contains the following:

/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
Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
Novice
  • 613
  • 1
  • 5
  • 17
  • Can you give the outcome when you executed `R CMD BATCH test.R`? Does this produce error? Also your OS and R versions information may help people to figure out. – Kota Mori Sep 15 '16 at 22:53
  • Have you tried `Rscript test.R' ? – J_F Sep 16 '16 at 07:44

1 Answers1

1

I solved this issue by following the steps laid out here.

  1. Symlinked it to my homebrew folder ln -s /opt/X11/include/X11 /usr/local/include/X11 (note that your homebrew directory may be different)
  2. brew install homebrew/dupes/tcl-tk
  3. brew link --overwrite --force tcl-tk; brew unlink tcl-tk brew reinstall -s r
Community
  • 1
  • 1
Novice
  • 613
  • 1
  • 5
  • 17