html_plot: Prints a R plot to a HTML file or console

View source: R/html_plot.r

html_plotR Documentation

Prints a R plot to a HTML file or console

Description

This function makes a HTML document including the defined plots

Usage

html_plot(
  plot,
  out,
  title = "plot",
  titlepr = NULL,
  footnote = "",
  pwidth = 1000,
  pheight = 600,
  res = NULL,
  fontsize = 12,
  units = "px",
  rawout = paste0(out, ".rawhtml"),
  cleancur = FALSE,
  ...
)

Arguments

plot

plot object or function call that creates plot to be printed to file

out

filename for the output HTML file

title

character string to define the title of the table which will be added to the caption

titlepr

character string to define the prefix of the table title. Can be used to create custom table numbering

footnote

character string with the footnote to be placed in the footer of the page (HTML coding can be used for example to create line breaks)

pwidth

numeric indicating the width of the plot to be generated in pixels

pheight

numeric indicating the height of the plot to be generated in pixels

res

numeric indicating the resolution of the plot, if set to NULL it will adapt the value according height of the plot

fontsize

character string with the default font or pointsize passed through to png function

units

character string with the units to use for plot width and height passed through to png function

rawout

character string with the name of the raw HTML file to generate (e.g. only plotting code) In case NULL no raw output will be generated. In order to combine results the filename should end in .raw.html

cleancur

logical indicating if the available plots should be deleted before creating new ones

...

additional arguments passed through to html_doc. Most important are template, rendlist, css and show

Value

The function returns a HTML file (or writes output to console)

Examples


# It is convenient to have an object for the plot argument
## Not run: 

  data(Theoph)
  library(ggplo2)
  pl <- qplot(Time, conc, data=Theoph, facets=~Subject,geom="line")
  html_plot(pl,out=paste0(tempfile(),".html"))

  # Base plots work a bit different and can be placed
  # in the function directly or wrapped in a function
  html_plot(plot(conc~Time,data=Theoph),out=tempfile(fileext=".html"))
  pl <- function() {
    plot(conc~Time,data=Theoph)
    title(main="a plot")
  }
  html_plot(pl(),out=tempfile(fileext=".html"))

## End(Not run)

R3port documentation built on Sept. 22, 2023, 9:06 a.m.