Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Last active March 4, 2016 17:19
Show Gist options
  • Save stephlocke/566d7d0858ecdb23603e to your computer and use it in GitHub Desktop.
Save stephlocke/566d7d0858ecdb23603e to your computer and use it in GitHub Desktop.
vegaliteerror
processing file: vegalitetest.Rmd
|........... | 17%
ordinary text without R code
|...................... | 33%
label: setup (with options)
List of 1
$ include: logi FALSE
|................................ | 50%
ordinary text without R code
|........................................... | 67%
label: vegalite
Quitting from lines 27-42 (vegalitetest.Rmd)
Error in vis$data[[name]] <- data :
invalid type/length (closure/0) in vector allocation
Calls: <Anonymous> ... eval -> _fseq -> freduce -> <Anonymous> -> add_data
Execution halted
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.6 vegalite_0.5.1.9000
loaded via a namespace (and not attached):
[1] htmlwidgets_0.6 clipr_0.2.0 magrittr_1.5 htmltools_0.3 tools_3.2.3 yaml_2.1.13
[7] rmarkdown_0.9.5.1 knitr_1.12.3 jsonlite_0.9.19 digest_0.6.9 chron_2.3-47
---
title: "Untitled"
author: "Steph Locke"
date: "4 March 2016"
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")
if(!require(data.table)) install.packages("data.table")
library(data.table)
seatbelts<-data.table(date=seq(as.Date("1969-01-01")
,as.Date("1984-12-01")
,by = "month")
, Seatbelts)[
,year:=year(date)
]
```
```{r vegalite}
library(vegalite)
library(data.table)
seatbelts<-data.table(date=seq(as.Date("1969-01-01")
,as.Date("1984-12-01")
,by = "month")
, Seatbelts)[
,year:=year(date)
]
vegalite() %>%
add_data(seatbelts) %>%
encode_x("PetrolPrice","quantitative") %>%
encode_y("DriversKilled", "quantitative") %>%
mark_point()
```
```{r ggvis}
library(ggvis)
seatbelts %>%
ggvis(~as.factor(date), ~DriversKilled) %>%
layer_bars()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment