tags:

views:

64

answers:

3

Is there an easy way to turn of all GUI elements in R and run it solely from the command line on OSX?

I'm trying to replicate the behavior of a remote linux terminal on my OSX machine. Thus plot() should just save a file and things like CRAN mirror selection should be text, not a Tk interface. I'm having trouble finding where to set this behavior.

A: 

I don't own an OS X box, but did you try to unset the X11 environment variable DISPLAY:

DISPLAY="" R --vanilla

When I do that on Linux and query R for capabilties(), x11 comes up as FALSE as desired.

Dirk Eddelbuettel
That does indeed disable x11, but leaves acqua and tcltk true. plot() still opens a quartz window.
Tristan
options(device=pdf)
Ian Fellows
+1  A: 

For the plots you can just direct the output to a file using the pdf() command (or png(), jpeg()...).

Matti Pastell
A: 

I don't run OSX but you could attempt to run R from the Terminal application, rather than the Mac OSX launcher, and see whether that runs as you need.

As Matti writes, you can send output to files using the following commands; but I don't know if that's really the substance of your question.

png("pngfile.png")
plot(foo)
title(main="bar")
dev.off()

So instead of the quartz graphical object, your output goes to the file.

Similarly, you can output what would normally appear in the terminal to a file.

sink("foo.file")
Ben M
Even the command line R opens a quartz window by default if the capability exists. The only way I've found to disable it is to compile R without aqua support but that's less than ideal.
Tristan