plot_save: Save Plots

Description Usage Arguments Examples

View source: R/plot_save.R

Description

Save and export plots with the specified names. Use pdf, bmp, png, jpeg or tiff to save the plot ouput to the specified directory.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
plot_save(
  p,
  w = NULL,
  h = NULL,
  res = 120,
  file = NULL,
  dir = NULL,
  format = "pdf",
  show.plot = TRUE,
  ...
)

pdf_save(p, w = 8, h = 6, file = NULL, dir = NULL, ...)

bmp_save(p, w = 800, h = 600, res = 120, file = NULL, dir = NULL, ...)

png_save(p, w = 800, h = 600, res = 120, file = NULL, dir = NULL, ...)

jpeg_save(p, w = 800, h = 600, res = 120, file = NULL, dir = NULL, ...)

tiff_save(p, w = 800, h = 600, res = 120, file = NULL, dir = NULL, ...)

Arguments

p

The ggplot object or gtable object.

w

The width of the plot ouput. If NULL (default), 8 for format = "pdf", 800 for format %in% c("bmp", "png", "jpeg", "tiff").

h

The height of the plot output. If NULL (default), 6 for format = "pdf", 600 for format %in% c("bmp", "png", "jpeg", "tiff").

res

The resolution of the plot ouput. Used if format %in% c("bmp", "png", "jpeg", "tiff"). The default value is 120.

file

The (path and) name of the file (including extention). If NULL (default), the file is saved to the current working directory with the name of the object p.

dir

The directory to save the plot. If NULL (default), the file is saved to the current working directory (or the path included in file argument). If both dir and file are specified, then the file is saved to the combined path of dir and file.

format

The format of the saving file. It can be chose from "pdf", "bmp", "png", "jpeg", "tiff"). Default value is "pdf".

show.plot

Print the plot at the end of function (boulean). The default is TRUE.

...

Additional arguments passed to the graphic device function specified in format.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Load Data
library(pscl)
data(vote92)

## Recode Variables
vote92$voteBush <- as.numeric(
  factor(vote92$vote,levels=c("Clinton","Bush")))*1 - 1
vote92$bushdis <- sqrt(vote92$bushdis)
vote92$clintondis <- sqrt(vote92$clintondis)

## Estimate Logistic Regression
fm <- formula(voteBush ~ dem + rep +
                clintondis + bushdis +
                persfinance + natlecon)
m <- glm(fm, data = vote92,
         family = binomial("logit"))

## Basic Graph
p <- plot_coef(m)
p

## Save Graph
plot_save(p)

gentok/estvis documentation built on April 2, 2020, 1:58 p.m.