R闪亮应用程序CI
问题描述:
我正在尝试构建我的第一个R Shiny应用程序。我想要建立一个置信区间模拟,其中侧面有滑块,当您更改某些内容(样本大小,置信度,标准偏差或平均值)时,置信区间长度的曲线会随着反应而变化。我从Shiny网站拿到了一个滑块示例,并尝试更改,但它不起作用。经过一些小的修改后,我收到了错误标签(“form”,list(...)):参数丢失,没有默认值“。另外,我不知道如何制作一个可信区间的好图,中间的意思是,你能协助吗? 我当前的代码是:R闪亮应用程序CI
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()
})
})
答
欢迎SO,和用于提供这种有据可查的示例祝贺。
由于嵌套结构,Shiny的错误消息是难以理解的,而且调试可能是令人讨厌的。代码中存在一些“次要”错误:
- 消息来自SliderInput(“samplesize”,...)之后的逗号,其中需要其他表达式。
- 在用户界面中,应该有一个更闭合 “)” data.frame()
- “S(S)amplesize” 是不一致拼写