我正试图用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
我想知道如何正确显示数据
答案 0 :(得分:0)
我已经尝试了你的例子,令人惊讶的是,情节出现在查看器面板中而不是在情节面板中。因此,将runtime: shiny
添加到您的YAML标题中:
---
title: "VegaLite test"
output: html_notebook
runtime: shiny
---