diffrOutput: Wrapper functions for using diffr in shiny

Description Usage Arguments Examples

View source: R/diffr.R

Description

Use diffrOutput to create a UI element, and renderDiffr to render the diff.

Usage

1
2
3
diffrOutput(outputId, width = "100%", height = "400px")

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

Arguments

outputId

Output variable to read from

width, height

The width and height of the diff (see shinyWidgetOutput)

expr

An expression that generates a diffr object

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.

Widget output function for use in Shiny

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
library(diffr)
library(shiny)
file1 = tempfile()
writeLines("hello, world!\n", con = file1)
file2 = tempfile()
writeLines(paste0(
"hello world?\nI don't get it\n",
paste0(sample(letters, 65, replace = TRUE), collapse = "")), con = file2)

ui <- fluidPage(
  h1("A diffr demo"),
  checkboxInput("wordWrap", "Word Wrap",
     value = TRUE),
   diffrOutput("exdiff")
)

server <- function(input, output, session) {
  output$exdiff <- renderDiffr({
    diffr(file1, file2, wordWrap = input$wordWrap,
    before = "f1", after = "f2")
  })
}

shinyApp(ui, server)

diffr documentation built on May 1, 2019, 7:24 p.m.

Related to diffrOutput in diffr...