display-shiny: Shiny Bindings for display

Description Usage Arguments See Also Examples

Description

Output and render functions for using the interactive image viewer within Shiny applications and interactive R Markdown documents.

Usage

1
2
3
displayOutput(outputId, width = "100%", height = "500px")

renderDisplay(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

expr

An expression that generates the image viewer (typicall through a call to display)

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

See Also

display

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
45
46
47
48
# Only run this example in interactive R sessions
if (interactive()) {
  options(device.ask.default = FALSE)

  require("shiny")
  
  ui <- fluidPage(
  
    # Application title
    titlePanel("Image display"),
  
    # Sidebar with a select input for the image
    sidebarLayout(
      sidebarPanel(
        selectInput("image", "Sample image:", list.files(system.file("images", package="EBImage")))
      ),
  
      # Show a plot of the generated distribution
      mainPanel(
        tabsetPanel(
          tabPanel("Static raster", plotOutput("raster")),
          tabPanel("Interactive browser", displayOutput("widget"))
        )
      )
    )
  
  )
  
  server <- function(input, output) {
  
    img <- reactive({
      f = system.file("images", input$image, package="EBImage")
      readImage(f)
    })
  
    output$widget <- renderDisplay({
      display(img())
    })
  
    output$raster <- renderPlot({
      plot(img(), all=TRUE)
    })
  
  }
  
  # Run the application
  shinyApp(ui = ui, server = server)
}

Example output



EBImage documentation built on Nov. 8, 2020, 5:41 p.m.