我有一些问题,包括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而不是删除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
答案 0 :(得分:0)
我对上述代码没有任何问题 - 我认为您不需要ggvisOutput("p")
或bind_shiny("p")
。删除后,它编译成一个闪亮的markdown文档,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:我已经在flash-markdown文档中包含了一个可重现的示例:
---
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)
```