我很擅长闪亮,而且我知道问题相当简单,但是尽管进行了大量的研究,我似乎无法获得闪亮的效果来测试比例的输出。我正在尝试创建一个脚本,用户输入所有参数(p1,p2,sig.level,power),并给出样本大小n。我尝试了很多不同的方法,但我通常最终没有输出,或者错误"' n'' p1',' p2& #39;,' 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)
答案 0 :(得分: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)
})
})
顺便说一句:我想知道你选择的sig.level
参数是0.95而power.prop.test
使用的默认值是0.05。