Chapter 2. An Overview of R Graphics

This chapter discusses how to export a graph and the differences between exploratory and presentation graphs. There is also a brief overview of several graphics systems in R. If you have some past programming experience or substantial experience with graphics, you will probably appreciate having this information before going on to the specifics of R graph types. If you’re not coming from that background, you might find this material a little too technical and unnecessary at this point. If so, go directly to Chapter 3 and come back to this one when you are ready for it.

Exporting a Graph

After you have made a graph, you will probably want to save it or put it in a document. How you do this will depend on what other software you are using. With some word processors, for instance, you can simply copy the graph by opening the graph window in R and clicking Copy in the Edit menu or a context menu connected to the graph. You can then paste it into the word processor.

Other software will require a little more effort on your part. If you have tried the copy-and-paste method and it does not work, you will need to choose a file type and instruct R to save your graph in this format, to a specific file. You can save the graph in any one of several formats, including .bmp, .pdf, .jpeg, .png, .tiff, .ps (PostScript), and others. The code example that follows shows how to save the graph we made in “Exercise 1-1.” to a .jpeg file, named test.jpeg (you could, ...

Get Graphing Data with R now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.