问题
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