Learn R Programming

Smisc (version 0.3.9.1)

openDevice: Opens a graphics device based on the filename extension

Description

Based on the filename extension, will open plotting device using one of the following graphics functions: postscript, pdf, jpeg, tiff, png, or bmp.

Usage

openDevice(fileName, ...)

Arguments

fileName

Character string giving the filename for the graphics output. The following are acceptable filename extensions: ps, pdf, jpg, jpeg, tif, png, or bmp.

Named arguments to the device functions listed above. Arguments that do not match are silently ignored.

Value

The graphics device is opened and the filename is invisibly returned.

Examples

Run this code
# NOT RUN {
# Open 3 example devices
openDevice("ex1.pdf", height=6, width=12)
plot(1:10, 1:10)

openDevice("ex1.jpg")
plot(1:10, 1:10)

openDevice("ex1.png")
plot(1:10, 1:10)

# List the devices and their filenames
dev.list()
dir(pattern = "ex1")

# Turn each of the 3 devices off
for (i in 1:3) {
  dev.off(dev.list()[length(dev.list())])
}

# Delete the created files
unlink(c("ex1.pdf","ex1.png","ex1.jpg"))

# List the current devices
dev.list()

# }

Run the code above in your browser using DataLab