RStudio SHINY不能使用ggvis [英] Rstudio shiny not able to use ggvis
本文介绍了RStudio SHINY不能使用ggvis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行了一个RStudio SHINY服务器,并从https://github.com/rstudio/ggvis安装了ggVIS,但我无法在该服务器中复制任何演示示例。
当我在服务器上安装的相同版本(3.1.0)上运行R时,我可以执行以下操作:
> library("shiny")
> library("ggvis")
The ggvis API is currently rapidly evolving. We strongly recommend that you do not rely on this for production, but feel free to explore. If you encounter a clear bug, please file a minimal reproducible example at https://github.com/rstudio/ggvis/issues. For questions and other discussion, please use https://groups.google.com/group/ggvis.
Attaching package: "ggvis"
The following object is masked from "package:stats":
filter
> ggvis::ggvisOutput
function (plot_id = rand_id("plot_id"))
{
ggvisOutputElements(plot_id, spec = NULL, shiny = TRUE)
}
<environment: namespace:ggvis>
但是当我在其中一个演示文件夹中尝试该示例时:
# ui.R
shinyUI(pageWithSidebar(
div(),
sidebarPanel(
sliderInput("n", "Number of points", min = 1, max = nrow(mtcars),
value = 10, step = 1),
uiOutput("plot_ui")
),
mainPanel(
ggvisOutput("plot"),
tableOutput("mtc_table")
)
))
# server.R
library("ggvis", lib.loc="/opt/R/R-3.1.0/lib64/R/library")))
shinyServer(function(input, output, session) {
# A reactive subset of mtcars
mtc <- reactive({ mtcars[1:input$n, ] })
# A simple visualisation. In shiny apps, need to register observers
# and tell shiny where to put the controls
mtc %>%
ggvis(~wt, ~mpg) %>%
layer_points() %>%
bind_shiny("plot", "plot_ui")
output$mtc_table <- renderTable({
mtc()[, c("wt", "mpg")]
})
})
我得到:
ERROR: could not find function "ggvisOutput"
用ggvisOutput
语句注释掉该行,然后正常呈现页面,但没有绘图。
有什么想法吗?
推荐答案
您的ui.R
文件中的ggvis
源(此处示例http://128.199.255.233:3838/userApps/john/ggvistest/
):
ui.R
library("ggvis")
shinyUI(pageWithSidebar(
div(),
sidebarPanel(
sliderInput("n", "Number of points", min = 1, max = nrow(mtcars),
value = 10, step = 1),
uiOutput("plot_ui")
),
mainPanel(
ggvisOutput("plot"),
tableOutput("mtc_table")
)
))
server.R
library(shiny)
library(ggvis)
shinyServer(function(input, output, session) {
# A reactive subset of mtcars
mtc <- reactive({ mtcars[1:input$n, ] })
# A simple visualisation. In shiny apps, need to register observers
# and tell shiny where to put the controls
mtc %>%
ggvis(~wt, ~mpg) %>%
layer_points() %>%
bind_shiny("plot", "plot_ui")
output$mtc_table <- renderTable({
mtc()[, c("wt", "mpg")]
})
})
这篇关于RStudio SHINY不能使用ggvis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文