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.
You can install the latest compareWith from GitHub using the remotes package
<span class="n">remotes</span><span class="o">::</span><span class="n">install_github</span><span class="p">(</span><span class="s2">"miraisolutions/compareWith"</span><span class="p">)</span><span class="w"> </span>
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 <span class="nt">-s</span> /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.
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
In case Meld is not installed, the current version is not working properly, or
location are not specified correctly, an error is displayed.