1

我遇到了问题,包括将 ggvis 绘制到闪亮降价中。例如,守则

---
title: "testShiny"
runtime: shiny
output: html_document
---

```{r, fig.height=3}

require(ggvis)
require(knitr)
require(shiny)

women %>%
  ggvis(x= ~height, y = ~weight) %>%
  layer_points()%>%
  bind_shiny("p")

ggvisOutput("p")


```

导致ggvisOutput无所事事,而线条

women %>%
  ggvis(x= ~height, y = ~weight) %>%
  layer_points()%>%
  bind_shiny("p")    

产生一个 Plot 而不是 declearing output$p。我认为bind_shiny(vis, id)是这里的问题。

任何想法如何解决这一问题?

PS:我的 sessionInfo()

R version 3.0.2 (2013-09-25)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8       
 [4] LC_COLLATE=de_DE.UTF-8     LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rmarkdown_0.2.55  markdown_0.7.3    shiny_0.10.1.9001 knitr_1.6.12           ggvis_0.3.0.99   

loaded via a namespace (and not attached):
 [1] assertthat_0.1  digest_0.6.4    dplyr_0.2       evaluate_0.5.5  formatR_0.10         htmltools_0.2.4
 [7] httpuv_1.3.0    magrittr_1.0.1  parallel_3.0.2  Rcpp_0.11.2     RJSONIO_1.3-0   stringr_0.6.2  
[13] tools_3.0.2     xtable_1.7-3    yaml_2.1.13   
4

1 回答 1

0

我对上面的代码没有任何问题——我认为你不需要那个ggvisOutput("p")bind_shiny("p"). 在我删除它之后,它编译成一个闪亮的降价文档,ggvis 显示得很好。这是我的会话信息:

R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_0.10.0   knitr_1.6      ggvis_0.3.0.99

loaded via a namespace (and not attached):
[1] assertthat_0.1   bitops_1.0-6     caTools_1.17     digest_0.6.4     dplyr_0.2       
[6] evaluate_0.5.5   formatR_0.10     htmltools_0.2.4  httpuv_1.3.0     magrittr_1.0.1  
[11] parallel_3.1.0   Rcpp_0.11.1      RJSONIO_1.2-0.2  rmarkdown_0.2.53 stringr_0.6.2   
[16] tools_3.1.0      xtable_1.7-3     yaml_2.1.11     

编辑:我通过 r-studio 编译:版本 0.98.977

你可能有一个旧版本的 shiny/knitr/ggvis/rstudio 。

EDIT2:我在闪亮的降价文档中包含了一个可重现的示例,该示例可以正确编译:

---
title: "testShiny"
runtime: shiny
output: html_document
---

```{r defineWidget, fig.height=3}
require(ggvis)
require(knitr)
require(shiny)

widget = function(dataset) {
  shinyApp(
    ui = navbarPage("test widget",
      tabPanel("Dataset",
        fluidPage(
          ggvisOutput("gg_plot")
        ) #fluid page
      ),  #tab panel

      #END TABS
      responsive = FALSE
    ), #ui  

    #SERVER
    server = function(input, output, session) {
      dataset %>% ggvis(x = ~mpg, y = ~hp) %>% layer_points() %>%
        bind_shiny("gg_plot")
    } #server

  ) #shinyAPP

}
```

```{r callWidget}
widget(mtcars)
```
于 2014-08-05T19:27:58.680 回答