Package (development) announcement: juxtaposer

Announcing {juxtaposer} — an {htmlwidget} package for embedding JuxtaposeJS image comparison tools into RMarkdown documents and {shiny} apps.
R
programming
interactive dataviz
dataviz
Published

October 11, 2019

As far as I can tell, there’s not yet an R package for building this kind of thing:

That’s why I’m going to build {juxtaposer}; a {htmlwidget} package for embedding these image comparison tools into both RMarkdown documents and {shiny} apps.

Here’s my initial design for how the package will be used (before any code or user testing, so it will likely change significantly!):

# function template
juxtaposer(data,
           juxtapose_size = list(width = "100%", height = "100%"),
           starting_position = "50%",
           show_labels = TRUE)

# data format
juxtaposer_imgs <- tribble(
  ~image_handedness, ~image_url,                  ~image_label,
  "left",            "img/r-logo_old.png",         "R logo (2000 - 2016)",
  "right",           "img/r-logo_new.png",         "R logo (2016 - today)"
)

I’m also going to blog the heck out of building this package. This is my third attempt to build a proper package, and all previous attempts have gone skewwhiff due to a lack of documentation.

Why call it juxtaposer?

This is a {htmlwidget} package, which means it wraps a JavaScript package into R code that we can use without writing any JS ourselves. JuxtaposeJS is the best looking and most feature-full option I found.

While the WYSIWYG tool on their website is fairly useful, it won’t allow us to modify the web element on the fly — for instance, changing the images programmatically, changing the slider position, or styling the web element. That’s what {juxtaposer} will give us.

I wanted it to be obvious to users of the package that it depends on JuxtaposeJS. It’s also fairly obligatory to insert an r into your package name if you can, and the lovely {available} package confirmed that {juxtaposer} is [currently] unused.