1
我正在嘗試構建我的第一個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()
})
})