【问题标题】:Shiny App not reacting when clicking points in R在 R 中单击点时闪亮的应用程序没有反应
【发布时间】:2020-07-21 19:06:35
【问题描述】:

我现在一直在尝试让我的 Shiny App 正常工作,这样当我将鼠标移动到绘图中的某些点时,它们会显示在表格中,但不幸的是它无法正常工作。 我不确定我做错了什么,你能帮帮我吗?

边框

ui ) )

服务器

output$Plot <- renderPlot({ 
    ggplot(table,aes(x=table$A, y=table$B), colour=border)) +
        geom_point() 
})

命中

output$HitSpots <- renderTable({
   hit()
}

}

shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: shiny reactive


    【解决方案1】:

    你的括号有问题。但主要的问题是你做了ggplot(table, aes(x=table$A, y=table$B)),然后nearpoints 正在寻找名为table$Atable$B 的列。请改用ggplot(table, aes(x=A, y=B))

    library(shiny)
    library(ggplot2)
    
    table <- data.frame(
      A = c(1,2,3),
      B = c(3,2,1)
    )
    
    ui <- fluidPage(
      mainPanel(
        plotOutput("Plot", click="plot_click"), 
        tableOutput("HitSpots")
      )
    )
    
    server <- function(input, output){
    
      output$Plot <- renderPlot({ 
        ggplot(table, aes(x=A, y=B)) + geom_point() 
      })
    
      hit <- reactive({ nearPoints(table, input$plot_click) })
    
      output$HitSpots <- renderTable({
        hit()
      })
    
    }
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-04
    • 2018-08-01
    • 2016-12-20
    • 2019-02-15
    • 2017-07-10
    • 1970-01-01
    • 2017-07-27
    • 2021-05-01
    相关资源
    最近更新 更多