2015-08-28 37 views
0

我有一個閃亮的應用程序,它在兩個獨立樣本之間進行t檢驗。基於單選按鈕選項,您可以輸入兩個樣本的彙總統計信息(\ bar {x},sd,n),也可以複製/粘貼或鍵入每個樣本的值。該renderUI功能看起來是這樣的:

output$ui<-renderUI({ 
     switch(input$option, 
      "Summary Stats" = 
       c(textInput("barx1","$$\\bar{x}_1$$", "0"), 
       textInput("picksd1", "$$sd_1$$", "1"), 
       textInput("n1","$$n_1$$","10"), 
       textInput("barx2", "$$\\bar{x}_2$$","1"), 
       textInput("picksd2", "$$sd_2$$","1"), 
       textInput("n2","$$n_2$$","10")), 
      "Input Data" = c(tags$textarea(id="foo1", rows=10, cols=38), tags$textarea(id="foo2", rows=10, cols=38))) 
    }) 

的textInputs渲染,並在UI做工精細,但文本框在這裏不這樣做,任何幫助嗎?我有一個非常相似的一個示例,其中foo1正常工作,問題似乎是我想要兩個文本框,也許我已經將它們存儲在c()表單中,儘管這對textInputs工作正常。預先感謝您的幫助。

回答

1

我設法通過使用html代碼而不是「tags」來完成這項工作。不知道爲什麼標籤$ textarea在c(標籤$ textarea,標籤$ textarea)形式使用時不起作用,但無論如何這看起來更清潔:

output$ui<-renderUI({ 
switch(input$option, 
     "Summary Stats" = HTML(
     '<div class="form-group shiny-input-container"> 
      <label for="barx1">$$\\bar{x}_1$$</label> 
      <input id="barx1" type="text" class="form-control" value="0"/> 
      </div> 
     <div class="form-group shiny-input-container"> 
      <label for="picksd1">$$sd_1$$</label> 
      <input id="picksd1" type="text" class="form-control" value="1"/> 
      </div> 
     <div class="form-group shiny-input-container"> 
      <label for="n1">$$n_1$$</label> 
     <input id="n1" type="text" class="form-control" value="10"/> 
     </div> 
     <div class="form-group shiny-input-container"> 
      <label for="barx2">$$\\bar{x}_2$$</label> 
     <input id="barx2" type="text" class="form-control" value="1"/> 
     </div> 
     <div class="form-group shiny-input-container"> 
      <label for="picksd2">$$sd_2$$</label> 
     <input id="picksd2" type="text" class="form-control" value="1"/> 
     </div> 
     <div class="form-group shiny-input-container"> 
      <label for="n2">$$n_2$$</label> 
     <input id="n2" type="text" class="form-control" value="10"/> 
     </div>' 
     ), 
     "Input Data" = HTML(
     '<div class="form-group shiny-input-container"> 
       <label for="foo1">Sample 1</label> 
     <textarea id="foo1" rows="10" cols="38"></textarea> 
     </div> 
     <div class="form-group shiny-input-container"> 
     <label for="foo2">Sample 2</label> 
     <textarea id="foo2" rows="10" cols="38"></textarea> 
     </div>' 
     )) 
     })