2016-08-20 34 views
1

我正在創建一個Shiny應用程序,其中一部分需要用戶輸入文本摘要,但出現在應用程序中的文本輸入框的默認大小非常小。用戶難以輸入3-4行的摘要。你能幫助我的腳本,可以使文本輸入框變大。非常感謝您的幫助!如何在R中添加更大的textInput框Shiny?

Snapshot from my App

=========== 我只是想用HTML標籤下面:

library(shiny) 

shinyUI(fluidPage(
    sidebarLayout(
    sidebarPanel(
     tags$textarea(id="my_textarea", rows=5, "Leave a comment...") 
    ), 
    mainPanel(
     uiOutput("my_output") 
    ) 
) 
)) 

但有一些錯誤 - 如下圖所示!

+0

我正在嘗試以下操作,但每次在我的Shiny應用中出現以下錯誤。 「ERROR:$操作是原子向量無效」 shinyUI(fluidPage( sidebarLayout( sidebarPanel( 標籤$文字區域(ID = 「my_textarea」,行數= 5, 「發表評論......」) ) , mainPanel( uiOutput(「my_output」) ) ) )) –

+0

它對我來說是按原樣工作的。顯示的唯一'$'是'tags $ textarea',如果你已經加載了閃亮(並且沒有定義另一個名爲'tags'的變量),它應該存在。 – alistaire

回答

1

我做了一個小的美學改變(CSS爲100%),但它確實按照原樣工作。錯誤可能來自代碼的其他部分。看下面的例子。

library(shiny) 

ui<-shinyUI(fluidPage(
    sidebarLayout(
    sidebarPanel( 
      tags$style(type="text/css", "textarea {width:100%}") , 
      tags$textarea(id="my_textarea", rows=5,placeholder = "Leave a comment...", value="") 
    ) 
    ,mainPanel(h4('My panel')) 
) 
)) 

server <- shinyServer(function(input, output) {}) 

shinyApp(ui, server) 
+0

非常感謝@Ron Talbot ...它添加了「shiny :: tags」 –

+0

'shinyUI(fluidPage( sidebarLayout( sidebarPanel( shiny :: tags $ style(type =「text/css」,「textarea {width:100%}「), shiny :: tags $ textarea(id =」my_textarea「,rows = 5,placeholder =」Leave a comment ...「,value =」「) ) ,mainPanel(h4 ('My panel')) ) ))' –

0

嘗試使用的textAreaInput代替textInput。使用前者可以設置高度和寬度,如果線太長,它會自動換行到下一行。

這似乎是這個問題的重複; Multi line text inputs in shiny

相關問題