Description Usage Arguments Examples
Use diffrOutput
to create a UI element, and renderDiffr
to render the diff.
1 2 3 | diffrOutput(outputId, width = "100%", height = "400px")
renderDiffr(expr, env = parent.frame(), quoted = FALSE)
|
outputId |
Output variable to read from |
width, height |
The width and height of the diff (see
|
expr |
An expression that generates a |
env |
The environment in which to evaluate |
quoted |
Is Widget output function for use in Shiny |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.