Description Usage Arguments Details Value Examples
These functions can be used in place of their corresponding base R functions to save plots as image files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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 ? |
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
.
These functions are used to open a plot device. Nothing is returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.