Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Created March 6, 2016 19:10
Show Gist options
  • Save stephlocke/620dc16e6d99bf7fc477 to your computer and use it in GitHub Desktop.
Save stephlocke/620dc16e6d99bf7fc477 to your computer and use it in GitHub Desktop.
vegalite incompatability with ggvis in rmarkdown
Error in vis$data[[name]] <- data :
invalid type/length (closure/0) in vector allocation
Calls: <Anonymous> ... eval -> _fseq -> freduce -> <Anonymous> -> add_data
Execution halted
---
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# Not on CRAN
if(!require(devtools)) install.packages("devtools")
if(!require(vegalite)) devtools::install_github("hrbrmstr/vegalite")
if(!require(ggvis)) install.packages("ggvis")
```
```{r vegalite, eval=TRUE}
library(vegalite)
vegalite() %>%
add_data(Seatbelts) %>%
encode_x("PetrolPrice","quantitative") %>%
encode_y("DriversKilled", "quantitative") %>%
mark_point()
```
```{r ggvis, eval=FALSE}
library(ggvis)
Seatbelts %>% data.frame %>%
ggvis(~PetrolPrice, ~DriversKilled) %>%
layer_points()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment