【问题标题】:Locating the textareaInput side by side(3 columns) at required position using R使用 R 在所需位置并排定位 textareaInput(3 列)
【发布时间】:2018-03-08 15:32:27
【问题描述】:

我正在运行 R 代码。我已经动态显示了 textareaInput。但是我在定位上有问题。

我得到的输出是: Desired Output

我期望的输出是分别在当前周、下周和下 2 周下方显示 textareaInput。

R 代码

observeEvent(input$view,{
output$inputGroup = renderUI({
  input_list <- lapply(1:(nrow(df())*3), function(i) {
    # for each dynamically generated input, give a different name
    inputName <- paste("input", i, sep = "")
    textInputRow<-function (inputId,value) 
    {
      div(style="display:inline-block",
          textAreaInput(inputName,"", width = "200px", height = "40px")
      )
    }

    column(4,
    textInputRow(inputName, ""))

  })
  do.call(tagList, input_list)
})

谁能帮我处理这段代码?

【问题讨论】:

  • 请尝试制作一个完全可重现的示例。此外,这看起来很闪亮,所以你应该在标题和标签中提到它。
  • 尝试使用fluidRowcolumn
  • 使用 fluidRow 在一列中产生输出@SBista
  • 理想情况下,您应该尝试使用引导模板,该模板可以帮助您仅使用 div 进行分栏github.com/amrrs/rshiny_html_template

标签: r shiny


【解决方案1】:

为了进一步阐述我对使用fluidRowcolumn 的评论,我在下面发布了一个示例代码:

   ui <- fluidPage(
     fluidRow(
       column(3, h3("Total Time Spent:")),
       column(3, numericInput("num1", "Current Week:", value = 1)),
       column(3, numericInput("num2", "Next Week:", value = 1)),
       column(3, numericInput("num3", "Next 2 Week:", value = 1))

     ),
     fluidRow(
       column(3),
       column(9,uiOutput("inputGroup"))
     )

   )



   server <- function(input,output){

     output$inputGroup = renderUI({
       input_list <- lapply(1:9, function(i) {
         # for each dynamically generated input, give a different name
         inputName <- paste("input", i, sep = "")
         textInputRow<-function (inputId,value) 
         {
           div(style="display:inline-block",
               textAreaInput(inputName,"", width = "200px", height = "40px")
           )
         }

         column(4,
                textInputRow(inputName, ""))

       })
       do.call(tagList, input_list)
     })

   }


   shinyApp(ui, server)

此代码生成如下输出:

希望对你有帮助!

【讨论】:

  • 谢谢。这对我帮助很大。 :-)
  • 如果对您有帮助,您能accept回答吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-20
相关资源
最近更新 更多