-1

我对闪亮还是很陌生,我知道你的问题相当简单,但尽管做了很多研究,我似乎无法让闪亮来渲染比例测试的输出。我正在尝试制作一个脚本,其中用户输入所有参数(p1,p2,sig.level,power),并给出样本大小 n。我尝试了许多不同的方法,但我通常最终没有输出,或者错误“'n'、'p1'、'p2'、'power'和'sig.level'中的一个必须为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)
4

1 回答 1

1

错误消息来自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)
  })
})

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

于 2016-06-17T05:53:27.763 回答