knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)

lifecycle

altqplot

This package is at the moment just a placeholder for one function, alt_qplot. Perhaps more functionality will get added, or this function will move elsewhere, or this package will continue as is...

The goal of alt_qplot is to provide qplot like functionality for the altair R package (which is a port of the Altair python package). Although altair (like ggplot) is very powerful thanks to the grammar of graphics framework, sometimes you want to very quickly make a plot and it is handy to be able to call one simple function. The purpose of the alt_qplot function in this package is to provide a convenient wrapper for quickly making a plot using altair. That plot can further be modified using altair methods, although when making anything beyond very simple plots, using altair directly should be preferred...

Examples

library(altqplot)
alt_qplot(x = mtcars$mpg)
alt_qplot(x = wt, y = mpg, data = mtcars)

You can also pass the encoding as strings. When doing so, you can specify the type (rather than altair picking its default):

alt_qplot(x = "wt", y = "mpg", color = "gear:N", data = mtcars)

You can also pass along altair's long form encoding:

alt_qplot(x = alt$X("wt:Q", bin = TRUE), 
          y = alt$X("mpg:Q", bin = TRUE), 
          size = "count()", 
          data = mtcars)

Future work

It might be useful to add a few more options to the alt_qplot function, such as facetting, although the goal is for this function to be pretty limited (b/c if you want something more complex you should use altair itself).

Maybe a Python version of this function/package? (although in python a simpler interface to vegalite already exists through pdvega, and all the nse nonsense in this function doesn't really have python equivalents afaik)



AliciaSchep/altqplot documentation built on May 30, 2019, 11:55 a.m.