我正在尝试构建我的第一个R Shiny应用程序。我想建立一个置信区间模拟,其中侧面有滑块,当你改变某些东西时(样本大小,置信水平,标准偏差或平均值),置信区间长度的图表会在反应中发生变化。我从Shiny网站上采取了一个滑块示例,并尝试更改,但它不起作用。经过一些小的改动后,我得到消息“标签中的错误(”形式“,列表(...)):缺少参数,没有默认值”。另外,我不知道如何制作一个很好的置信区间图,中间的平均值,你能帮忙吗? 我目前的代码是:
library(shiny)
# Define UI for slider demo application
shinyUI(fluidPage(
# Application title
titlePanel("Confidence Interval for the mean when sigma is known"),
# Sidebar with sliders that demonstrate various available
# options
sidebarLayout(
sidebarPanel(
# Simple integer interval
sliderInput("mean", "Mean:",
min=0, max=500, value=250),
# Decimal interval with step value
sliderInput("confidence", "Confidence level:",
min = 0, max = 1, value = 0.95, step= 0.01),
# Specification of range within an interval
sliderInput("sigma", "Standard deviation:",
min = 0, max = 300, value = 10),
# Provide a custom currency format for value display,
# with basic animation
sliderInput("Samplesize", "Sample size:",
min = 0, max = 1000, value = 30, step = 1),
),
# Show a table summarizing the values entered
mainPanel(
tableOutput("values")
)
)
))
和
library(shiny)
# Define server logic for slider examples
shinyServer(function(input, output) {
# Reactive expression to compose a data frame containing all of
# the values
sliderValues <- reactive({
# Compose data frame
data.frame(
Name = c("Mean",
"Confidence Interval",
"Standard Deviation",
"Sample size"),
Value = as.character(c(input$mean,
input$confidence,
input$sigma,
input$samplesize),
stringsAsFactors=FALSE)
})
# Show the values using an HTML table
output$values <- renderTable({
sliderValues()
})
})
答案 0 :(得分:2)
欢迎来到SO,并祝贺提供了这样一个记录良好的例子。
由于嵌套结构,Shiny的错误消息是难以理解的,并且调试可能很糟糕。您的代码中存在一些“次要”错误: