vdiffr (version 0.2.2)

htmlwidgets: HTML Widgets for graphical comparison

Description

These widgets can be used at the console and embedded in a R Markdown document or Shiny application.

Usage

widget_toggle_(before, after, width = NULL, height = NULL)

widget_slide_(before, after, width = NULL, height = NULL)

widget_diff_(before, after, width = NULL, height = NULL)

widget_toggle(before, after, width = NULL, height = NULL)

widget_slide(before, after, width = NULL, height = NULL)

widget_diff(before, after, width = NULL, height = NULL)

Arguments

before

The picture that is taken as reference.

after

The picture against which the reference is compared.

width

Fixed width for widget (in css units). The default is NULL, which results in intelligent automatic sizing based on the widget's container.

height

Fixed height for widget (in css units). The default is NULL, which results in intelligent automatic sizing based on the widget's container.

Details

The regular versions take plots or functions as before and after arguments (see expect_doppelganger() for details). The versions suffixed with underscores take HTML image sources. These can be paths to SVG files or inlined SVG images. Currently, widget_diff_() is compatible only with inlined images.

Examples

Run this code
# NOT RUN {
p1 <- function() hist(mtcars$disp)
p2 <- function() hist(mtcars$drat)

# You can also call these functions in a R Markdown document or
# in a Shiny application:
widget_toggle(p1, p2)
widget_slide(p1, p2)
widget_diff(p1, p2)
# }

Run the code above in your browser using DataCamp Workspace