2016-06-17 8 views
-1

私はかなり光り輝いていて、私はyの質問はかなりシンプルですが、多くの研究をしていますが、光り輝くように見えません比率の力の出力をテストします。ユーザーがすべてのパラメータ(p1、p2、sig.level、power)を入力し、サンプルサイズnが与えられたスクリプトを作成しようとしています。私はいろいろな方法を試しましたが、出力がないか、 "n、p1、p2"、 "power"、 "sig.level" 。どんな助けもありがとう、ありがとう!これまでサンプルサイズのためのpower.prop.test関数の光沢のある出力

私のコード:

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

実際にキャップされていないR関数の名前を大文字にしないでください。それは他の初心者を混乱させる。 (エラーメッセージは合理的にはっきりしているようですが、あなたは1つの引数を与え、その関数は4つを期待しています) –

+0

申し訳ありませんが、私はまた、すべての引数(p1、p2、sig.levelとpower)を提供するときにエラーが発生すると付け加えます。 –

+0

"Power.Prop.Test function" –

答えて

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) 
    }) 
}) 

power.prop.testは0.05のデフォルト値を使用している間、私は0.95のsig.levelパラメータの選択に疑問を抱きました。

+0

これをクリアしてくれてありがとう! –

+0

あなたは私の答えに感謝してうれしいです。あなたは左のチェックマークをクリックして私の答えを受け入れるのですか?ありがとうございました。 – Uwe

関連する問題