首页 > 解决方案 > 使用 RenderPlot 在 R 中显示图形

问题描述

我之前在地块上工作过。这次我面临plot功能问题。

UI.r页:

    shinyUI(fluidPage(

  # Application title
  titlePanel("test"),
  sidebarLayout(
    ),
    # Show a plot of the generated distribution
    mainPanel(
       plotOutput("distPlot")
    )
  )
))

服务器.r 页面:

browser()
output$distPlot <- renderPlot({
plot(cars)
})

如果我在该行代码处设置断点,它会跳转上面的脚本并转到下一行代码。我不明白为什么这段代码不起作用。最初我认为这可能是因为我用于显示的数据但它也没有打印默认数据集数据。

谁能说出这个脚本中可能的原因或错误。

即使尝试使用dev.off()它也会引发以下错误:

警告:dev.off 中的错误:无法关闭设备 1(空设备)

使用browse()上面的代码行后:

Browse[1]> n
debug at /server.R#8: output$distPlot <- renderPlot(plot(cars))
Browse[2]> n
debug at server.R#52: return(df2)

谢谢你的帮助!

标签: rplotshinydata-visualizationinteractive

解决方案


推荐阅读