我正在运行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)
})
任何人都可以帮我这个代码吗?
答案 0 :(得分:0)
要进一步详细说明我对使用fluidRow
和column
的评论,我将在下面发布示例代码:
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)
此代码按如下方式生成输出:
希望它有所帮助!