Learn R Programming

loon.ggplot (version 1.0.1)

l_ggplot: Automatically create a loon widget

Description

l_ggplot() wraps function ggplot with assigning a new class "lggplot" to the output ggplot object and returns a lggplot object. When a ggplot object is processed, S3 method print.ggplot is rendered, however, if a lggplot object is processed, S3 method print.lggplot will be rendered which will return a loon widget

Usage

l_ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

Arguments

data

Default dataset to use for plot. If not already a data.frame, will be converted to one by fortify(). If not specified, must be supplied in each layer added to the plot.

mapping

Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot.

...

Other arguments passed on to methods. Not currently used.

environment

DEPRECATED. Used prior to tidy evaluation.

Value

It will return a lggplot object with class c("lggplot", "gg", "ggplot"). Then print a loon plot automatically.

See Also

ggplot, ggplot2loon, print.lggplot

Examples

Run this code
# NOT RUN {
if(interactive()) {
  p <- l_ggplot(mpg, aes(displ, cty)) +
     geom_point() +
     facet_grid(rows = vars(drv))
  # p is a `lggplot` object, `print.lggplot(p)` is called automatically.
  # Then, the `lggplot` object will be transformed to a `loon` widget
  p
}
# }
# NOT RUN {
  # get widgets from current path
  # suppose the path of `p` is '.l0.ggplot'
  q <- l_getFromPath('.l0.ggplot')
  # q is a `loon` widget
  q
# }

Run the code above in your browser using DataLab