首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rstudio发亮,无法使用ggvis

Rstudio发亮,无法使用ggvis
EN

Stack Overflow用户
提问于 2014-07-24 13:43:41
回答 1查看 4.2K关注 0票数 4

我有一个RStudio闪亮的服务器正在运行,我从https://github.com/rstudio/ggvis安装了ggvis,但是我无法在服务器中复制任何演示示例。

当我在服务器上安装相同版本的R (3.1.0)时,我可以执行以下操作:

代码语言:javascript
复制
> 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>

但是,当我在其中一个演示文件夹中尝试这个示例时:

代码语言:javascript
复制
# 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语句注释掉行,然后正常呈现页面,但没有情节。

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-24 15:14:29

ggvis在您的ui.R文件中(例如这里的http://128.199.255.233:3838/userApps/john/ggvistest/):

ui.R

代码语言:javascript
复制
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

代码语言:javascript
复制
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")]
  })
})
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24935452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档