Skip to content

Instantly share code, notes, and snippets.

Motivation

I see our project as a set of two transformations: one that changes a ggplot2 object into a ggspec, then another that changes a ggspec into a Vega-Lite spec.

The analogy may not be exact, but I see these transformations in terms of linear algebra, where a ggplot2 object is a vector in "ggplot" space, a ggspec is a vector in "ggspec" space, and a Vega-Lite spec is a vector in "Vega-Lite" space.

One of our goals is that "ggspec"-space should be a faithful representation of "ggplot2"-space. One way of doing this is to make sure that the "transformation-matrix" is as close to diagonal as we can make it. As Haley likes to point out, the ggplot2 object is a "list of 9"; therefore the "ggspec" object will have no more than 9 elements (maybe it will not have a "theme"?).

If we wanted to (and we don't want to), we could reproduce the ggplot2 object using the ggspec.

@ijlyttle
ijlyttle / .Renviron
Last active April 8, 2019 01:15
Generic R setup files
# An .Renviron file helps keep you safe, by storing secrets in one place that
# you can secure.
# - to open *your* .Renviron file, usethis::edit_r_environ()
# - please make sure that your .Renviron file ends with a newline,
# or R will ignore it
# - this is a minimal file, you will likely want to add your own "stuff"
# - if you need to deal with a firewall, this is the place to define
# your proxy variables
#
# More information: https://whattheyforgot.org/r-startup.html#renviron
@ijlyttle
ijlyttle / .gistr
Created January 11, 2019 18:01
An mtcars example.
gistr
@ijlyttle
ijlyttle / .block
Created January 11, 2019 05:12
An mtcars example.
license: mit
height: 500
scrolling: yes
border: yes
@ijlyttle
ijlyttle / .block
Last active December 13, 2018 23:42
vega-view changeset works as expected
license: mit
height: 500
scrolling: yes
border: yes
@ijlyttle
ijlyttle / .block
Last active December 13, 2018 23:34
vega-view changeset does not work as expected
license: mit
height: 500
scrolling: yes
border: yes
@ijlyttle
ijlyttle / .block
Last active November 19, 2018 01:42
Vega-Lite: Trying to combine selections
license: mit
height: 500
scrolling: yes
border: yes
library("rlang")
library("dplyr")
library("purrr")
myfil <- function(data, names, vals) {
exprs <- purrr::map2(names, vals, ~ quo(!!sym(.x) == !!.y))
print(quo(dplyr::filter(data, !!!exprs)))
Include something like this in your Rmd to "turn-off" the borders for all accordion displayed content-panels.
```{css}
.panel-success {
border-width: 0;
}
```

[email protected]

Ian Lyttle

Schneider Electric


I have been a tidyverse contributor for almost six years. For the past year-and-a-half, I have been working in partnership with Iowa State University to advance the use of interactive graphics in R.