loon.shiny: Automatically Create a 'shiny' App Based on Interactive...

Description Usage Arguments Details Value Examples

View source: R/loon.shiny.R

Description

Interactive loon widgets displayed in a shiny app

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
loon.shiny(
  widgets,
  selectBy = c("byDefault", "brushing", "sweeping"),
  showWorldView = TRUE,
  plotRegionWidth = "500px",
  plotRegionHeight = "500px",
  plotRegionBackground = "gray92",
  layoutMatrix = NULL,
  nrow = NULL,
  ncol = NULL,
  widths = NULL,
  heights = NULL,
  displayedPanel = "",
  colorList = loon::l_getColorList(),
  inspectorLocation = c("auto", "auto", "60px", "20px"),
  inspectorWidth = "350px",
  inspectorHeight = "auto",
  toolboxWidth = "300px",
  toolboxLocation = c(10, -20),
  options = list(),
  ...
)

Arguments

widgets

A loon widget or a list of loon widgets. If the input is a ggplot object, the ggplot object will be turned into a loon widget via ggplot2loon.

selectBy

The way to brush, can be 'brushing' (keep the brush whenever the plot is updated), 'sweeping' (clear the brush whenever the plot is updated) or 'byDefault' (determined by loon widget 'selectBy')

showWorldView

Logical; whether to show the world view.

plotRegionWidth

Plot region width. Must be a valid CSS unit (like '100 which will be coerced to a string and have 'px' appended.

plotRegionHeight

Plot region height.

plotRegionBackground

Plot region background color

layoutMatrix

Optional layout matrix to place loon widgets. See layout_matrix in grid.arrange.

nrow

Number of rows, see grid.arrange.

ncol

Number of columns, see grid.arrange.

widths

A unit vector giving the width of each plot.

heights

A unit vector giving the height of each plot.

displayedPanel

A string vector. The default is an empty string "" so that none inspector components (Plot, Linking, Select, etc) are open automatically. The available strings are c("Plot", "Select", "Linking", "Modify", "Layer", "Glyph")

colorList

A list of colors displayed on modify panel.

inspectorLocation

A length four vector representing the distance between the bottom, left, top and right of the inspector panel and the bottom, left, top and right of the page or parent container.

inspectorWidth

Width of the inspector panel.

inspectorHeight

Height of the inspector panel.

toolboxWidth

The width of a toolbox

toolboxLocation

The position of a toolbox (if any) which is a length two numerical vector ("pixel") representing the location (x, y) of the top-left corner. A positive x pushes the toolbox to the right of the mouse and a positive y pushes the toolbox down.

options

shinyApp argument that should be passed to the runApp call, see shinyApp.

...

Named arguments to modify shiny app.

Details

Value

A shiny.appobj object that represents the loon.shiny app. Printing the object or passing it to runApp will run the app.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Only run this example in interactive R sessions
if(interactive()) {
  ############## Querying ##############
  lp <- with(mpg,
             l_plot(displ, hwy,
                    showItemLabels = TRUE,
                    itemLabel = with(mpg,
                      paste0("model:", manufacturer, " ",
                              model, "\n",
                             "year:", year, "\n",
                             "drive way:", drv, "\n",
                             "fuel type:", fl)),
                    color = "black"))
  loon.shiny(lp)

  ############### Link multiple plots ###############
  p1 <- l_plot(iris,
               linkingGroup = 'iris',
               showLabels = FALSE)
  p2 <- l_hist(iris$Sepal.Length,
               linkingGroup = 'iris',
               showLabels = FALSE,
               showStackedColors = TRUE)
  p3 <- l_hist(iris$Sepal.Width, linkingGroup = 'iris',
               color = iris$Species, sync = 'push',
               showLabels = FALSE, swapAxes = TRUE,
               showStackedColors = TRUE)
  loon.shiny(list(p1, p2, p3),
             layoutMatrix = matrix(c(2,NA,1,3),
             nrow = 2, byrow = TRUE))

if (requireNamespace('loon.ggplot', quietly = TRUE)) {
    # ggplot -> loon -> shiny
    p <- ggplot(mpg, aes(displ, hwy)) +
      geom_point(data = transform(mpg, class = NULL), colour = 'grey85') +
      geom_point() +
      facet_wrap(~class)
    g <- loon.ggplot(p,
                     activeGeomLayers = 2,
                     itemLabel = mpg$model) # active the second layer
    # with facets
    loon.shiny(g, toolboxWidth = "100px")
}
}

loon.shiny documentation built on Sept. 28, 2021, 1:06 a.m.