ggedit: Interactive shiny gadget for editing ggplot layers and...

Description Usage Arguments Details Value See Also Examples

View source: R/ggedit.R

Description

Shiny gadget that takes an input ggplots and populates a user interface with objects that let the user update aesthetics of layers and theme elements.

Usage

1
ggedit(p.in, ...)

Arguments

p.in

ggplot plot object or list of objects

...

options that are passed to ggedit

Details

The user can start the gadget using the console ggedit(plotobj) or through the Addins menu in Rstudio.

If you are using the the Addin option highlight on the editor window the ggplot object and then click the addin.

Options to pass to ggedit

viewer shiny viewer options. It can be either paneViewer (default with minHeight=1000), dialogViewer, browserViewer

verbose logical to control if the output includes script for layers and themes calls for parsing to create objects (default, verbose=TRUE)

showDefaults toggle to control if the verbose output shows all the input arguments passed to the proto object (if verbose==FALSE then ignored)

width,height dimensions of the renderPlot where the active plot is displayed

Once the gadget is running the list of plots are shown in a grid and a number of objects will appear above them.

Action buttons

Cancel:

Returns a NULL object

Done:

Returns the list decribed below.

Dropdown list

Navigates through the plots in the input list. If the input list is a named list the names will be in the dropdown. The plot chosen is termed as the "active plot"

Radio buttons

The options to choose in the radio buttons are the layer names in the active plot.

Links

Update Plot Layer:

A pop up window will appear and be populated with aesthetic elements found in the layer chosen from the radio buttons. The layer is cloned using cloneLayer creating a layer independent of the original plot. If the aesthetic is a factor the values will be shown in dropdown lists. If it is numeric it will be shown in a slider. If it is a factor colour/fill aesthetic the colourPicker package will allow to choose from the full pallete of colours. If the continuous colour/fill aesthetic a dropdown list will be shown with different palletes

Update Plot Theme:

A popup modal will appear populated with the theme elements found in the active plot. Each element will appear as having a value or empty depending if it was defined or not. The user can change or fill in any element with valid values and any textboxes left empty will use ggplot defaults.

Update Grid Theme:

Copies the theme of the active plot to the other plots in the list

Update Global Theme:

Copies the theme of the active plot to the session theme and all plots created outside of the gadget will have this theme.

View Layer Code:

Opens an ace editor to compare the active layer initial script call and the updated script call.

The ggplot objects returned (layers and themes) can be used on any ggplot object.

Value

List of elements

updatedPlots

list containing updated ggplot objects

updatedLayers

For each plot a list of updated layers (ggproto) objects

UpdatedLayersElements

For each plot a list elements and their values in each layer

UpdatedLayerCalls

For each plot a list of scripts that can be run directly from the console to create a layer

updatedScales

For each plot a list of updated scale objects

UpdatedScalesCalls

For each plot a list of scripts that can be run directly from the console to create a scale object

updatedThemes

For each plot a list of updated theme objects

UpdatedThemeCalls

For each plot a list of scripts that can be run directly from the console to create a theme

See Also

cloneLayer,rgg,ggplot,colourPicker

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
p <- ggplot2::ggplot(iris,ggplot2::aes(x =Sepal.Length,y=Sepal.Width))

p <- p + 
ggplot2::geom_point(ggplot2::aes(colour=Species)) + 
ggplot2::geom_line()

if(interactive()){
## Not run: 
pnew <- ggedit(p)
pnew

## End(Not run)
}

Example output

Loading required package: shiny
Loading required package: shinyBS
Loading required package: ggplot2
Loading required package: dplyr

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

ggedit documentation built on July 8, 2020, 5:34 p.m.