私は、システム開発のための自動化を提供する光沢のあるアプリケーションを開発しています。ユーザー入力用のテキストボックスを追加し、その結果のユーザー入力をrenderText()出力に追加する方法が必要です。私は反作用の値をループする方法があるかどうか分からないので、今はtextInput()の結果のラベルに特定の呼び出しを行わなければなりません。コードを変更する必要がある部分は、サーバ部分の下部に出力$値一部であることに注意して、以下の通りです:RシャイニーのrenderText()出力にinsertUI()出力を追加するにはどうすればよいですか?
library(shiny)
ui <- fluidPage(
fluidRow(
column(6,
textInput("mainDesc1", label = "Main Description", value = "", width = '100%')
),
column(1,
actionButton(inputId = 'insertBtn', label = "More")
),
column(1,
actionButton(inputId = 'removeBtn', label = "Less")
)
),
tags$div(id = 'placeholder'),
fluidRow(column(12, verbatimTextOutput("value")))
)
server <- function(input, output) {
## keep track of elements inserted and not yet removed
inserted <- c()
#btn <- 1
observeEvent(input$insertBtn, {
btn <- input$insertBtn + 1
id <- paste0("mainDesc", btn)
insertUI(
selector = '#placeholder',
## wrap element in a div with id for ease of removal
ui = tags$div(
tags$p(fluidRow(
column(6,
textInput(paste("mainDesc", btn + 1, sep = ""), label = "", value = "", width = '100%')
)
)
),
id = id
)
)
inserted <<- c(id, inserted)
})
observeEvent(input$removeBtn, {
removeUI(
## pass in appropriate div id
selector = paste0('#', inserted[length(inserted)])
)
inserted <<- inserted[-length(inserted)]
})
output$value <- renderText({ noquote(paste(input[[paste("mainDesc", 1, sep = "")]], "\n",
input[[paste("mainDesc", btn + 1, sep = "")]], sep = ""))
})
}
shinyApp(ui = ui, server = server)
はどうすればよいようにポップアップユーザ入力の結果()箱以上のループ結果:
textInput(paste("mainDesc", btn + 1, sep = ""), label = "", value = "", width = '100%')
上記のすべての既存の出力を貼り付けるにはどうすればよいですか?基本的に、私が探しているのは、ユーザーが最初の「主な説明」テキストボックスに「1行目」を入力し、「詳細」ボタンをクリックしてポップアップするテキストボックスに「2行目」を追加し、ポップアップテキストボックスにタイプ「3行目」renderText()ボックス出力:
1st line
2nd line
3rd line
複数のテキストボックスが追加された場合、ユーザ入力がrenderText()出力にライン・バイ・ラインを追加する必要があります。ありがとう!
これは私がまさに必要である:
はここにコードを動作しているようだ何を参照してください! –