compareWith: Easy diff and merge in RStudio

[This article was first published on Mirai Solutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We are happy to announce the R package compareWith, providing user-friendly RStudio addins that simplify diff and merge tasks.

Just ahead of the upcoming useR!2019 Toulouse, where Miraier Nikki will be introducing the package in a short talk during one of the lightning sessions (Thursday morning – July 11), we are pleased to put this small utility out here, which has brought some noticeable enhancement to our day-to-day R development process over the past year.

Integration of version control tools in R and RStudio is still significantly behind what is desirable. With the uprise of GitHub and git for open-source R package development, issues are being tackled through separate branches and contributors are more numerous and heterogeneous. compareWith is a R package that allows users to interact with Meld from within RStudio through addins, making it easier to perform diff and merge tasks. Examples include:

  • compare differences prior to commit, for single active files or the whole project;
  • editing files or directories;
  • resolve merge conflicts via three-way comparison.


Resolve merge conflicts with compareWith

Installation

You can install the latest compareWith from GitHub using the remotes package

remotes::install_github("miraisolutions/compareWith")

The required dependency Meld is available for most Linux/Unix distributions and can be easily installed there, e.g. via sudo apt install meld on Debian/Ubuntu.

On Windows, its installation is supported by an MSI installer, downloadable from the Meld website. We recommend using the 3.18.3 installer (as hinted on the website), since newer versions seem to have Gtk issues. After installation, you may have to add the location of the installed meld.exe to the PATH environment variable.

Meld is not yet officially supported on MacOS. However, pre-built binaries are available as meldmerge.dmg images for new and old releases of Meld. We currently recommend using Meld 3.16.0, as newer versions do not appear to be stable. After installation, you need to make sure meld can be launched from the command line, e.g. via:

ln -s /Applications/Meld.app/Contents/MacOS/Meld /usr/local/bin/meld

Meld can also be installed via MacPorts, Fink or Brew, where you may also have to switch to an older stable version.

Usage

The functionality of compareWith is accessible in RStudio using the Addins menu or the command-line functions. Examples include:

  • compare_with_repo(path) allows to track changes in file(s) under path (belonging to a version-control repository);
  • compare_active_file_with_other(location) allows the user to compare the currently opened file with another (browsing from location).

In case Meld is not installed, the current version is not working properly, or path or location are not specified correctly, an error is displayed.

To leave a comment for the author, please follow the link and comment on their blog: Mirai Solutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)