power.prop.test 函数的闪亮渲染输出样本大小

Shiny-rendering output of power.prop.test function for sample size

我对闪亮很陌生,我知道你的问题很简单,但尽管做了很多研究,但我似乎无法闪亮地渲染比例幂测试的输出。我正在尝试制作一个脚本,用户输入所有参数(p1、p2、sig.level、power),并给出样本大小 n。我尝试了很多不同的方法,但通常以没有输出或错误 "exactly one of 'n', 'p1', 'p2', 'power', and 'sig.level' must be NULL" 而告终。感谢您的帮助,谢谢!

到目前为止我的代码:

    ui<-shinyUI(fluidPage(
    headerPanel("Power Calculator"),
    fluidRow(
    column(12,
       wellPanel(
         helpText("This calculator can help you understand the power of 
                  your experimental design to detect treatment effects. You     
        can choose 
                  between a standard design in which individuals are randomly   
       assigned to treatment or control 
                  and a clustered design, in which groups of individuals are assigned to treatment 
                  and control together."),
         column(4,
                wellPanel(

         numericInput('p1a','prop1', value = 0.12, min = 0.01, max = 0.99),
         numericInput('p2a', 'prop2', value = 0.14, min = 0.01, max = 0.99),
         numericInput('sig.levela','significance level' , value = 0.95, min = 0.9, max = 0.99),
         numericInput('powera', 'power level', value = 0.8, min = 0.75, max = 0.99)
                ),
         column(8,
                wellPanel(
                  htmlOutput("nrequired")

                )
         )
         )
         )
         )
         )
         )
         )
         )

         server<-shinyServer(
        function(input, output) {



        sample.size<-reactive({
  p1<-input$p1a
  p2<-input$p2a
  sig.level<-input$sig.level$a
  power<-input$power.levela

})


output$nrequired <- renderPrint({
power.prop.test(sample.size)
print(sample.size)
})

}
)

shinyApp(ui=ui,server=server)

错误消息来自 power.prop.test,这是由于将反应式表达式 sample.size 作为参数传递给它而引起的。

请尝试修改服务器功能如下:

server <- shinyServer(function(input, output) {
  output$nrequired <- renderPrint({
    power.prop.test(p1 = input$p1a, p2 = input$p2a, 
                    sig.level = input$sig.levela, power = input$powera)
  })
})

顺便说一句:我想知道您选择的 sig.level 参数为 0.95,而 power.prop.test 使用默认值 0.05。