绘制ylim in Shiny

时间:2016-04-07 13:50:09

标签: r plot shiny

我正在编写一个应用程序,该应用程序应该生成一个直方图,其中滑块可以移动平均值跨越儿童的高尔顿数据集(UsingR包)的高度。

该应用返回错误:

Error in plot.window(...) : need finite 'ylim' values
像往常一样,我检查了NA。一切都好。实际上,在正常条件下绘制直方图没有问题(没有Shiny)。我是Shiny的新手,当然我错过了那里的东西。遗憾的是,here遇到了类似的问题。

用户界面文件:

library(shiny)

shinyUI(pageWithSidebar(
headerPanel("Example plot"),
sidebarPanel(
    sliderInput('mu', 'Guess the mean', value = 70, min = 62, max = 74, step = 0.05)
),
mainPanel(
    plot('newHist')
)
)) 

服务器文件:

library(UsingR)
data(galton)

shinyServer(
function(input, output){
    output$newHist <- renderPlot({
        hist(galton$child, xlab = 'child height', col = 'lightblue', main = 'Histogram')
            mu <- input$mu
            lines(c(mu, mu), c(0, 200), col = "red", lwd = 5)
            mse <- mean((galton$child - mu)^2)
            text(63, 150, paste("mu = ", mu))
            text(63, 140, paste("MSE = ", round(mse, 2)))
        })
}
)

0 个答案:

没有答案