简体   繁体   English

在闪亮的文档中显示ggvis图

[英]Display a ggvis plot in a shiny document

Is ggvis working with Shiny Documents yet? ggvis是否正在使用Shiny Documents?

In this example, ggplot is visible but ggvis is not 在这个例子中,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()

  })

```

While searching I came across bind_shiny, but it didn't solve the problem 在搜索时遇到了bind_shiny,但它没有解决问题

You need to use bind_shiny to assign an id to the visualisation. 您需要使用bind_shiny为可视化分配id。 You then need to use ggvisOutput to create an element in the DOM to display the visualisation: 然后,您需要使用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