| pdf_print | R Documentation | 
A convenience function that either displays a plot object in an R graphics window or saves it to a PDF.
  pdf_print(
    plot_obj,
    width = 7,
    height = 7,
    save_to_pdf = FALSE,
    file = NULL,
    new_window = TRUE,
    ...
  )
| plot_obj | A plotting object that can be printed, such as a trellis object returned by
a call to  | 
| width | The width of the figure in inches. | 
| height | The width of the figure in inches. | 
| save_to_pdf | When  | 
| file | A file name to use when  | 
| new_window | When printing  | 
| ... | Additional arguments to be passed to  | 
This function is helpful when developing and using analysis scripts. In this
context, it is recommended to define a boolean called SAVE_TO_PDF early
in the script and to always use pdf_print when creating figures,
passing the boolean as the save_to_pdf input argument. Figures can be
initially displayed in R (setting SAVE_TO_PDF = FALSE), and then saved
as PDFs once graphing parameters have been optimized (setting
SAVE_TO_PDF = TRUE).
Note that calling pdf from the command line (as is done
internally by pdf_print) is different than exporting an R graphics
object as a PDF from RGui or RStudio. For some reason, RGui and RStudio
override some of the pdf defaults and set useDingbats to
TRUE. This setting almost always causes problems when opening the PDFs
in software like Adobe Illustrator or Inkscape.
The pdf_print function does not return anything.
SAVE_TO_PDF = FALSE # change this to TRUE to save to a PDF
pdf_print(
  lattice::xyplot(
    1:4 ~ 11:14,
    xlab = 'X',
    ylab = 'Y',
    type = 'b'
  ),
  save_to_pdf = SAVE_TO_PDF,
  file = 'example.pdf', # this name will only be used when saving to a PDF
  new_window = FALSE    # necessary for rendering the documentation examples
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.