【问题标题】:Display a ggvis plot in a shiny document在闪亮的文档中显示 ggvis 图
【发布时间】:2014-07-05 17:08:27
【问题描述】:

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,但并没有解决问题

【问题讨论】:

    标签: r shiny ggvis


    【解决方案1】:

    您需要使用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")
    
    ```
    

    【讨论】:

    • 完美运行,谢谢。你知道为什么ggvisOutput("p") 必须在调用情节之前来吗?
    • 我认为顺序不重要。我只是倾向于将 ui.R 对象放在 server.R 之前。
    猜你喜欢
    • 2016-02-22
    • 1970-01-01
    • 2016-10-11
    • 2015-09-25
    • 2017-03-15
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    • 2015-06-23
    相关资源
    最近更新 更多