Learn R Programming

microbenchmark (version 1.5.0)

autoplot.microbenchmark: Autoplot method for microbenchmark objects: Prettier graphs for microbenchmark using ggplot2

Description

Uses ggplot2 to produce a more legible graph of microbenchmark timings.

Usage

autoplot.microbenchmark(
  object,
  ...,
  order = NULL,
  log = TRUE,
  unit = NULL,
  y_max = NULL
)

Value

A ggplot2 object.

Arguments

object

A microbenchmark object.

...

Ignored.

order

Names of output column(s) to order the results.

log

If TRUE the time axis will be on log scale.

unit

The unit to use for graph labels.

y_max

The upper limit of the y axis, in the unit automatically chosen for the time axis (defaults to the maximum value).

Author

Ari Friedman, Olaf Mersmann

Examples

Run this code
if (requireNamespace("ggplot2", quietly = TRUE)) {
    tm <- microbenchmark(rchisq(100, 0),
                         rchisq(100, 1),
                         rchisq(100, 2),
                         rchisq(100, 3),
                         rchisq(100, 5), times=1000L)
    ggplot2::autoplot(tm)

    # add a custom title
    ggplot2::autoplot(tm) + ggplot2::ggtitle("my timings")
}

Run the code above in your browser using DataLab