[英]Display a ggvis plot in a shiny document
ggvis是否正在使用Shiny Documents?
在這個例子中,ggplot是可見的,但ggvis不是
---
title: "testShiny"
runtime: shiny
output: html_document
---
ggplot2
```{r, echo=FALSE}
require(ggplot2)
renderPlot({
ggplot(women, aes(height, weight))+
geom_point()+
theme_bw()
})
```
ggvis
```{r, echo=FALSE}
require(ggvis)
renderPlot({
women %>%
ggvis(x= ~height, y = ~weight) %>%
layer_points()
})
```
在搜索時遇到了bind_shiny,但它沒有解決問題
您需要使用bind_shiny
為可視化分配id。 然后,您需要使用ggvisOutput
在DOM中創建一個元素來顯示可視化:
---
title: "testShiny"
runtime: shiny
output: html_document
---
```{r, echo=FALSE}
require(ggvis)
require(knitr)
require(shiny)
ggvisOutput("p")
women %>%
ggvis(x= ~height, y = ~weight) %>%
layer_points()%>%
bind_shiny("p")
```
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.