| Title: | HTML Widget to Show File Differences |
|---|---|
| Description: | A HTML widget that shows differences between files (text, images, and data frames). |
| Authors: | Hadley Wickham [aut, cre], Joshua Kunst [aut], Winston Chang [aut], Posit Software, PBC [cph, fnd], Paul Fitzpatrick [cph] (Author of included daff.js library), Rodrigo Fernandes [cph] (Author of included diff2html library), JQuery Foundation [cph] (Author of included jquery library), Kevin Decker [cph] (Author of included jsdiff library), Matthew Holt [cph] (Author of incldued PapaParse library), Huddle [cph] (Author of included resemble library) |
| Maintainer: | Hadley Wickham <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2.9000 |
| Built: | 2025-11-14 06:13:47 UTC |
| Source: | https://github.com/r-lib/diffviewer |
Currently supports:
image diffs for.svg and.png
tabular diffs for.csv
text diffs for everything else
visual_diff(file_old, file_new, width = NULL, height = NULL)visual_diff(file_old, file_new, width=NULL, height=NULL)
file_old,file_new | Paths to files to compare |
width,height | Output size |
A HTML widget
visual_diff_output() for use within Shiny apps
path1 <- tempfile()path2 <- tempfile()writeLines(letters, path1)writeLines(letters[-13], path2)if (interactive()) { visual_diff(path1, path2)}path1<- tempfile()path2<- tempfile()writeLines(letters, path1)writeLines(letters[-13], path2)if(interactive()){ visual_diff(path1, path2)}
visual_diff()Usevisual_diff_output() in ui andrender_visual_diff(visual_diff(...))in the server function.
visual_diff_output(outputId, width = "100%", height = "400px")visual_diff_render(expr, env = parent.frame(), quoted = FALSE)visual_diff_output(outputId, width="100%", height="400px")visual_diff_render(expr, env= parent.frame(), quoted=FALSE)
outputId | output variable to read from |
width,height | Must be a valid CSS unit (like |
expr | An expression that generates a visual_diff |
env | The environment in which to evaluate |
quoted | Is |
Components for use inside a Shiny app.
if (require("shiny") && interactive()) {ui <- fluidPage( visual_diff_output("diff"))server <- function(input, output, session) { path1 <- tempfile() path2 <- tempfile() writeLines(letters, path1) writeLines(letters[-13], path2) output$diff <- visual_diff_render(visual_diff(path1, path2))}shinyApp(ui, server)}if(require("shiny")&& interactive()){ui<- fluidPage( visual_diff_output("diff"))server<-function(input, output, session){ path1<- tempfile() path2<- tempfile() writeLines(letters, path1) writeLines(letters[-13], path2) output$diff<- visual_diff_render(visual_diff(path1, path2))}shinyApp(ui, server)}