2017-09-27 34 views
0

我正在運行R代碼。我已經動態地顯示了textareaInput。但是我有一個定位問題。使用R在所需位置並排定位textareaInput(3列)使用R

我得到的輸出是: 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

請嘗試做一個完全可重複的例子。此外,這看起來像閃亮,所以你應該在標題和標籤中提及。 – Spacedman

+0

嘗試使用'fluidRow'和'列' – SBista

+0

使用** fluidRow **在一列中生成輸出@SBista –

回答

0

爲了進一步闡述我的評論使用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) 

此代碼生成的輸出如下:

enter image description here

希望它能幫助!

+0

**感謝**。這對我幫助很大。 :-) –

+0

你可以[接受](https://stackoverflow.com/help/someone-answers)答案,如果它幫助你? – SBista