繁体   English   中英

在闪亮的文档中显示ggvis图

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM