prBmp {tinyProject} | R Documentation |
Save plots as image files
Description
These functions can be used in place of their corresponding base R functions to save plots as image files.
Usage
prBmp(name, ..., replace = FALSE)
prJpeg(name, ..., replace = FALSE)
prPng(name, ..., replace = FALSE)
prTiff(name, ..., replace = FALSE)
prPdf(name, ..., replace = FALSE)
prSvg(name, ..., replace = FALSE)
prCairoPdf(name, ..., replace = FALSE)
prCairoPs(name, ..., replace = FALSE)
Arguments
name |
Name of the output file, without extension. One can also specify subdirectory where to save the file. |
... |
parameters passed to the corresponding base R function. For
instance, for |
replace |
If the file already exists, should it be overwritten ? |
Details
These functions has three advantages over the base functions:
Files are automatically created in the output folder of the project even if the working directory has changed. Subdirectories are automatically created if they do not exist.
By default, these functions do not erase an existing file. This avoids accidents.
The default values of the parameters (width, height, etc.) can be modified with function
prOutputDefaults
.
Value
These functions are used to open a plot device. Nothing is returned.
Examples
projectPath <- file.path(tempdir(), "test")
prInit(projectPath)
prPng("test")
plot(rnorm(100))
dev.off()
# The plot is saved in "output/test.png"
list.files(projectPath, recursive = TRUE, include.dirs = TRUE)
prPng("mysubdirectory/test")
plot(rnorm(100))
dev.off()
# The plot is saved in "output/mysubdirectory/test.png"
list.files(projectPath, recursive = TRUE, include.dirs = TRUE)