【问题标题】:Multiple tags$textarea boxes within renderUI function shinyrenderUI函数中的多个标签$ textarea框闪亮
【发布时间】:2015-08-28 00:47:32
【问题描述】:

我有一个闪亮的应用程序,可以在两个独立样本之间进行 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)))
    })

文本输入在 UI 中呈现和工作正常,但文本框没有,这里有什么帮助吗?对于一个示例案例,我有一些非常相似的东西,其中 foo1 工作正常,问题似乎是我想要两个文本框,也许我将它们存储在 c() 形式中,尽管这对 textInputs 工作正常。提前感谢您的帮助。

【问题讨论】:

    标签: textbox shiny


    【解决方案1】:

    我设法通过使用 html 代码而不是“标签”来完成这项工作。不知道为什么 tags$textarea 在以 c(tags$textarea, tags$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>'
           ))   
          })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 1970-01-01
      • 2015-08-03
      • 1970-01-01
      相关资源
      最近更新 更多