Compare and Verify File Contents

Extendable 'R6' file comparison classes, including a 'shiny' app for combining the comparison functionality into a file comparison application. The package idea originates from pharma companies' drug development processes, where statisticians and statistical programmers need to review and compare different versions of the same outputs and datasets. The package implementation itself is not tied to any specific industry and can be used in any context for easy file comparisons between different file version sets.


verifyr2

CRAN status Coverage Coverage Status

verifyr2 is an R package for extendable file comparison classes and methods including an example shiny app for combining the functions into a convenient application.

Package installation

The project is available in cran and can be installed with the following command:

> install.packages("verifyr2")

Development version

The latest development version can be installed from github using different install packages that work with github projects. One such option would be to use the devtools package:

> install.packages("devtools")
> library("devtools")
> install_github("ejuhjav/verifyr2")

Extended functionality

Following additional libraries can be installed to extend the provided comparison functionality:

> # image comparison functionality
> install.packages("magick")
>
> # pdf comparison functionality
> install.packages("pdftools")

Shiny app usage

Launching the shiny app requires that you have the following additional libraries installed as documented in the suggestion list; shinyjs, shinyFiles, and DT. After all the necessary libraries are available, the included shiny app can be launched with the following command:

> verifyr2::run_example()

Creating and calling the separators manually

> config <- Config$new()
> comparator <- verifyr2::create_comparator(file1, file2)
> comparator$vrf_summary(config = config)
> comparator$vrf_details(config = config)

instantiating an explicit comparator manually

> config <- Config$new()
> comparator <- RtfFileComparator$new(file1, file2)
> comparator$vrf_summary(config = config)
> comparator$vrf_details(config = config)

Optional features

Image comparison features - comparing single images as well as supported embedded images in file contents - requires additional magick library to be installed. This is defined as an optional requirement for the verifyr2 package due to the additional OS level requirements of the package. For more details on the package installation, see magick package.

PDF comparison features - reading PDF file contents as text for details comparison - requires additional pdftools library to be installed. This is defined as an optional requirement for the verifyr2 package due to the additional OS level requirements of the package. For more details on the package installation, see pdftools package.

Adding support to additional file types

The file comparison logic is implemented with a generic structure that supports easy addition of new comparison logic for different file types. In most cases, this will simply require an implementation of a new file comparator with the file extension name and implementing the file contents getter. The included simplified implementation for pdf file comparison - without testing pdftools availability and excluding the logging parts - is an example of how to do this (see source file to see the full implementation with documentation).

When using the provided generic create_comparator function along with your custom comparator class implementation, note that the comparator class name prefix must match with the compared file type.

#' PdfFileComparator.R
#'
#' @include TxtFileComparator.R
#'
#' @export
#'
PdfFileComparator <- R6::R6Class(
  "PdfFileComparator",
  inherit = TxtFileComparator,
  public = list(
    vrf_contents = function(file, config, omit) {
      content <- pdftools::pdf_text(file)
      content <- paste(content, collapse = "")
      content <- strsplit(content, "\n")[[1]]

      self$vrf_contents_inner(content, omit, options)
    }
  )
)

Contributing

Contributions to verifyr2 are dynamic and welcome! Whether you are fixing a typo, reporting a bug, or building a brand-new file comparator, we appreciate your help.

Please see our Contributing Guide for details on our code style, test requirements, and how to set up your local R development environment.

Credits

verifyr2 package implementation is based on the concept of the verifyr package.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("verifyr2")

1.3.0 by Juha Javanainen, 3 months ago


Browse source code at https://github.com/cran/verifyr2


Authors: Juha Javanainen [aut, cre] , Tiina Kirsilä [ctb] , Anna Wiksten [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports base64enc, diffobj, dplyr, htmltools, jsonlite, magrittr, mime, R6, rappdirs, shiny, stringr, striprtf, tibble

Suggests DT, fs, magick, pkgload, pdftools, purrr, readxl, rmarkdown, shinyjs, shinyFiles, shinytest2, testthat


See at CRAN