gpt4 book ai didi

Rstudio Shiny 无法使用 ggvis

转载 作者:行者123 更新时间:2023-12-04 12:15:24 25 4
gpt4 key购买 nike

我有一个 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 注释掉该行语句然后正常呈现页面但没有绘图。

有任何想法吗?

最佳答案

来源 ggvis在您的 ui.R文件(此处的示例 http://128.199.255.233:3838/userApps/john/ggvistest/):

用户界面

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")
)
))

服务器
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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24935452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com