Как отладить ggplot в режиме браузера в пределах блестящего? - PullRequest
2 голосов
/ 10 января 2020

Мы проверяли реактивное значение, используя browser , но когда ggplot не отображает ожидаемый график, как мы можем отладить его в реактивном режиме?

library(shiny)

ui <- basicPage(
  plotOutput("plot1", click = "plot_click"),
  verbatimTextOutput("info")
)

server <- function(input, output) {
  output$plot1 <- renderPlot({
    browser() # Here, the browser stops but when run the below line, cannot see the plot in plots tab
    plot(mtcars$wt, mtcars$mpg) # or ggplot ...both not rendering plot in browser mode
  })

  output$info <- renderText({
    paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
  })
}

shinyApp(ui, server)

1 Ответ

3 голосов
/ 10 января 2020

На самом деле, вы можете запросить открытие нового устройства:

Listening on http://127.0.0.1:7460
Called from: renderPlot(...)
Browse[1]> plot(mtcars$wt, mtcars$mpg) ## won't plot
Browse[1]> dev.new() ## opens a new window
Browse[1]> plot(mtcars$wt, mtcars$mpg) ## now plots
...