my dog learned polymorphism
The moose likes Other Languages and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Other Languages
Bookmark ""R" graph output" Watch ""R" graph output" New topic

"R" graph output

Augusto Sellhorn
Ranch Hand

Joined: May 24, 2007
Posts: 57
Hi Robert;

Just read the intro to your book, very interesting stuff. This is the first time I've read about the "R" language, but it sounds like something I should be looking at since part of my job is to find interesting ways to visualize data.

Now the graphs you create in "R", how are they output, are they displayed on a top level window when you run "R" programs or is there more control for the output, say save it is a PNG, or output to a stream? I'm just wondering how you capture the graphical output if you wanted to say show the results in a webpage.

Oh and BTW, is "R" a JVM language? I get the impression it is not, but just wondering ...


Robert Kabacoff
Ranch Hand

Joined: Mar 28, 2011
Posts: 33
Hi Augusto,

When you run R interactively, you have the choice of directing a graph to device window (the default) and/or saving it to a pdf, png, jpeg or postscript file. Multiple images can be saved in a single pdf. On windows, you can also save the image as a windows metafile (wmf) or bmp file.

So for example, if I execute the command
at an interactive prompt, a window will pop open with the graph displayed. I can save the file to multiple formats from menu options in that window.

If I execute the command
at an interactive prompt, the graph is saved to the file mygraph.png.

If you run an R script in batch, then you would want to write the graph to a file.

BTW, there are R packages (e.g., R2HTML) that will help you to embed R graphics in web pages easily.

R is not a JVM language.
I agree. Here's the link:
subject: "R" graph output
It's not a secret anymore!