“raw”- scaling of interactive shiny plot

我的梦境 提交于 2020-01-16 02:08:32

问题


I tried to make a interactive plot within a navbarpage shiny app.

The problem is that the range of the input$plot_click$xvalues (and the input$plot_brush$xminvalues ...) is [0;1] - they are not scaled to the data. So I can´t use these values to identifiy rows or something like that.

Here is the ui.R code

library(shinythemes)

shinyUI(navbarPage("Kursqualität",theme = shinytheme("united"),
               tabPanel("Abstrakte Qualitätsdimensionen",          
                        sidebarLayout(
                          sidebarPanel(
                            h4("test")
                           ),

                          mainPanel(  
                            plotOutput("dummyplot",
                                       click = "plot_click",
                                       brush = brushOpts(
                                         id = "plot_brush")
                            ),

                            h4("Clicked points"),
                            verbatimTextOutput("selected_rows"),

                            h4("Brushed points"),
                            verbatimTextOutput("brush_info")                              

                          )
                        )
               ),


               tabPanel("Konkrete Qualitätsmerkmale"

                          ),

               tabPanel("Marketingeffekt"
                        )
))

And here is the server.R code library(ggplot2)

shinyServer(function(input, output, session) {


output$dummyplot <-  renderPlot({dp <- ggplot(mtcars, aes(qsec, disp)) + geom_jitter()
                                 print(dp)
                      })


output$brush_info <- renderPrint({str(input$plot_brush)
                     })



output$selected_rows <- renderPrint({str(input$plot_click)
                        })


})

I also created a gist, you can run it via

library(shiny)
runGist("d138bf3e6a4996ffb8de")

Thank´s in advance Samuel


回答1:


It seems, the problem is caused by print. If you return just dp everything works fine.

output$dummyplot <-  renderPlot({
    dp <- ggplot(mtcars, aes(qsec, disp)) + geom_jitter()
    dp 
  })


来源:https://stackoverflow.com/questions/32494233/raw-scaling-of-interactive-shiny-plot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!