我正在尝试使用 vegalite 在 sweeve/knitr 中显示一些图,但我得到的只是一个没有图的空白区域。
我的代码如下,它基于一个教程示例:
---
title: "VegaLite test"
output: html_notebook
---
```{r}
library(vegalite)
library(magrittr)
```
```{r barplot, fig.width=8, fig.height=6}
dat <- jsonlite::fromJSON('[
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
]')
vegalite() %>%
add_data(dat) %>%
encode_x("a", "ordinal") %>%
encode_y("b", "quantitative") %>%
mark_bar() -> vl
vl
```
我在用:
> packageVersion("vegalite")
[1] ‘0.7.1’
> packageVersion("magrittr")
[1] ‘1.5’
> packageVersion("knitr")
[1] ‘1.15.1’
RStudio: Version 1.0.136
> R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.3
year 2017
month 03
day 06
svn rev 72310
language R
version.string R version 3.3.3 (2017-03-06)
nickname Another Canoe
我想知道我应该怎么做才能看到正确显示的数据