r-lib / diffviewer Goto Github PK
View Code? Open in Web Editor NEWHTML widget to visually compare files
Home Page: http://diffviewer.r-lib.org
License: Other
HTML widget to visually compare files
Home Page: http://diffviewer.r-lib.org
License: Other
It would be nice if diffviewer allowed to also compare dataframes.
For my own use, I created the small helper function below that creates tempfiles from the dataframes to be able to use diffviewer:
compare_DFs <- function(DF_new, DF_old) {
OLD = tempfile(pattern = "OLD_", fileext = ".csv")
NEW = tempfile(pattern = "NEW_", fileext = ".csv")
readr::write_csv(DF_old, OLD)
readr::write_csv(DF_new, NEW)
diffviewer::visual_diff(OLD, NEW)
}
http://www.speqmath.com/tutorials/csv2array/ doesn't have any licensing information so we can't use it.
@jbkunst can you please find an alternative?
With svglite this works:
file1 <- tempfile(fileext = ".svg")
file2 <- tempfile(fileext = ".svg")
svglite::svglite(file1); plot(1:3); dev.off()
svglite::svglite(file2); plot(2:4); dev.off()
diffviewer::visual_diff(file1, file2)
But SVGs generated by vdiffr are not displayed:
file3 <- tempfile(fileext = ".svg")
file4 <- tempfile(fileext = ".svg")
vdiffr::write_svg(function() plot(1:3), file3, "plot1")
vdiffr::write_svg(function() plot(2:4), file4, "plot2")
diffviewer::visual_diff(file3, file4)
I don't know if the SVGs generated by @thomasp85's version of the vdiffr engine work with diffviewer. Do you have this branch online Thomas?
Even if the new engine works, it would be nice for vdiffr users to be able to compare the old SVGs to the new ones when they transition to vdiffr 1.0. Or we just assume the SVGs to be equivalent?
Using selection of examples from http://rpubs.com/jbkunst/diffviewer
With these two files, there are a few pixels that are different, but the visual diff does not color them in red.
However, magick::image_compare()
does show the differences.
oldfile <- "file1.png"
newfile <- "file2.png"
library(magick)
old <- magick::image_read(oldfile)
new <- magick::image_read(newfile)
# Shows difference
image_compare(old, new)
# Does not show difference
library(diffviewer)
diffviewer::visual_diff(oldfile, newfile)
This is the difference image generated by image_compare()
. I've added arrows pointing to the pixels that are different.
Here's the info about the pixels that are different:
old_data <- old[[1]]
new_data <- new[[1]]
idx <- old_data != new_data
which(idx, arr.ind = TRUE)
#> dim1 dim2 dim3
#> [1,] 1 512 185
#> [2,] 2 512 185
#> [3,] 3 512 185
#> [4,] 1 512 196
#> [5,] 2 512 196
#> [6,] 3 512 196
#> [7,] 1 1022 670
#> [8,] 2 1022 670
#> [9,] 3 1022 670
#> [10,] 1 1022 686
#> [11,] 2 1022 686
#> [12,] 3 1022 686
#> [13,] 1 1022 1136
#> [14,] 2 1022 1136
#> [15,] 3 1022 1136
old_data[idx]
#> [1] 0f 82 fe 0e 81 fe e6 e6 e6 d7 d7 d7 e6 e6 e6
new_data[idx]
#> [1] 00 7b ff 00 7b ff e7 e7 e7 d8 d8 d8 e7 e7 e7
cc @nstrayer
Prepare for release:
devtools::build_readme()
usethis::use_cran_comments()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
cran-comments.md
Submit to CRAN:
usethis::use_version('minor')
devtools::submit_cran()
Wait for CRAN...
usethis::use_news_md()
usethis::use_github_release()
usethis::use_dev_version()
The master
branch of this repository will soon be renamed to main
, as part of a coordinated change across several GitHub organizations (including, but not limited to: tidyverse, r-lib, tidymodels, and sol-eng). We anticipate this will happen by the end of September 2021.
That will be preceded by a release of the usethis package, which will gain some functionality around detecting and adapting to a renamed default branch. There will also be a blog post at the time of this master
--> main
change.
The purpose of this issue is to:
message id: euphoric_snowdog
There is one in inst/htmlwidgets, and another in inst/htmlwidgets/lib/diffviewer. They are mostly the same, but not exactly, and I believe there should probably be just one copy of it.
This is something I've wanted for a while: to be able to just view a directory of files, without diffs. That would be useful for when the initial snapshots are created.
usethis::use_package_doc()
@importFrom
directives here.usethis::use_import_from()
is handy for this.usethis::use_testthat(3)
and upgrade to 3e, testthat 3e vignetteR/
files and test/
files for workflow happiness.usethis::use_r()
include a helpful script.usethis::rename_files()
may be be useful.usethis::use_tidy_description()
usethis::use_tidy_dependencies()
usethis::use_tidy_github_actions()
and update artisanal actions to use setup-r-dependencies
cran-comments.md
Authors@R
of DESCRIPTION like so, if appropriate:person("RStudio", role = c("cph", "fnd"))
usethis::use_tidy_coc()
master
--> main
issuesdevelopment
is mode: auto
in pkgdown configusethis::use_lifecycle()
Necessary:
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
Run devtools::document()
to re-generate package-level help topic with DESCRIPTION changesuse_mit_license()
use_tidy_logo()
usethis::use_tidy_coc()
usethis::use_tidy_github_actions()
Optional:
pak::pak("org/pkg")
over devtools::install_github("org/pkg")
in READMEuse_tidy_dependencies()
and/or replace compat files with use_standalone()
use_standalone("r-lib/rlang", "types-check")
instead of home grown argument checkersCreated on 2023-10-30 with usethis::use_tidy_upkeep_issue()
, using usethis v2.2.2.9000
VS code uses .dark-mode
: https://code.visualstudio.com/api/extension-guides/webview#theming-webview-content
pkgdown uses [data-bs-theme="dark"]
Prepare for release:
git pull
urlchecker::url_check()
devtools::build_readme()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
cran-comments.md
git push
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version(push = TRUE)
Maybe make automatically pick the ratio to find the largest size that still fits in the window?
Prepare for release:
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
cran-comments.md
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
The text diff viewer currently only shows the changed portion with a few lines of context. It would be useful to be able to expand the context, similar to GitHub's diff viewer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.