相关疑难解决方法(0)

如何将数据从反应性Shiny表达式传递到ggvis图?

我正在熟悉ggvis,我正试图在闪亮中使用它.我无法理解ggvis如何从反应性Shiny表达式中获取数据.这是ggvis GitHub存储库的基本应用程序:

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")
  )
))
Run Code Online (Sandbox Code Playgroud)

server.R:

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()[, …
Run Code Online (Sandbox Code Playgroud)

r shiny ggvis

10
推荐指数
1
解决办法
3748
查看次数

标签 统计

ggvis ×1

r ×1

shiny ×1