RpadGraphing: Rpad graphing utilities

Description Usage Arguments Details Value Side Effects Author(s) See Also Examples

Description

Utilities to make graphing in Rpad R scripts easier.

Usage

1
2
3
  graphoptions(..., reset = FALSE, override.check = TRUE)
  newgraph(name = "")
  showgraph(name = get("plot.name", envir = .RpadEnv), link = FALSE, ...)

Arguments

reset, override.check

logical arguments passed to check.options.

name

is the name of the graph with the extension left OFF.

link

is a logical specifying whether to show a link to allow the user to download an EPS file of the graph (not available when using R's png driver.

...

named arguments assigned as defaults for newgraph.

Details

The graphoptions, newgraph, and showgraph set of functions allows quick setup and display of web-friendly graphics. In an Rpad page, the user can normally just use any of the plot commands followed by showgraph. newgraph sets up the graphics device, and it's called when the Rpad package starts. showgraph generates the HTML to show the graph and runs newgraph to advance to the next graphics file. Graphics files are by default named Rpad\_plot1, Rpad\_plot2, and so on. Named graphs can also be used, but there's more of a chance that if the user has caching set wrong (or the server's caching is set wrong) that graphs won't update properly in the user's browser. With the default sequential numbering of files, caching problems are less likely.

Internally, newgraph uses one of two devices to generate the bitmap for the browser. Specifying type="Rpng" directs newgraph to use R's png device directly. The type="pngalpha" option outputs to a postscript device, followed by ghostscript conversion to PNG with anti-aliasing. This approach has the side-effect of creating an EPS file for each graph, so it's easy to add a link to allow the user to download the EPS file.

graphoptions is available to change the parameters from their defaults. It can be called interactively (before running Rpad()) or in the server version (in RpadStartup.R).

Value

None of the routines returns a value: all are run for their side effects.

Side Effects

newgraph opens a new graphics device, saving files with the pattern Rpad_plot.*.png (and Rpad_plot.*.eps for pngalpha) in the working directory.

Author(s)

Tom Short, EPRI, (tshort@epri.com)

See Also

See also bitmap, png, and pdf.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# make some graphs (a default graphics device is already available)
  x <- 1:10
  y <- x^2
  y2 <- x^3
  if (capabilities("png")) graphoptions(type="Rpng")
  newgraph()
  plot(x, y)  # does the plot
  plot(x, y2) # does the second plot
  HTMLon()    # sets Rpad to HTML output
  showgraph() # closes the device, outputs the HTML for the both
              # images, and creates the next device
  plot(x, y2)
  showgraph()

# graphs with named files:
  newgraph("graph_A")
  plot(x, y)
  showgraph("graph_A")
# also adjust the width and height
  graphoptions(width = 4, height = 6)
  newgraph("graph_B")
  plot(x, y2)
  showgraph("graph_B")

Rpad documentation built on May 2, 2019, 4:43 p.m.