我有一个 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
然后正常呈现页面但没有绘图。
有任何想法吗?