1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
---
title: "Using ggvis with knitr and rmarkdown"
output:
html_document:
fig_width: 4
fig_height: 2
---
```{r echo=FALSE}
# Set up default dimensions. Width and height are multiplied by dpi to get
# pixel dimensions.
knitr::opts_chunk$set(fig.width = 4, fig.height = 3)
```
To embed a ggvis plot just call `ggvis`:
```{r, message = FALSE}
library(ggvis)
mtcars %>% ggvis(x = ~wt, y = ~mpg) %>% layer_points()
```
```{r, fig.width = 8, fig.height = 6}
mtcars %>% ggvis(x = ~wt, y = ~mpg) %>%
layer_points() %>%
layer_smooths()
```
|