我们曾经使用浏览器检查无功值,但是当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)
实际上,您可以要求打开新设备:
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句