【发布时间】:2018-02-25 21:18:35
【问题描述】:
我正在使用随机字母给出的标签动态创建一个 actionButton(简化示例)。单击按钮后,我希望将标签粘贴到文本输入中。
library(shiny)
runApp(list(ui=
shinyUI(fluidPage(
mainPanel(
textInput("text", label = ""),
div(style="display:inline-block", uiOutput("wordOneButton"))
)
))
,
server=shinyServer(function(session, input, output) {
# Fill the buttons with the random letter
output$wordOneButton <- renderUI({
actionButton("action", label = LETTERS[sample(1:length(LETTERS), 1)])})
# Include predicted word in the text after click event on button
observeEvent(input$action, {
name <- paste0(input$text, ????????, sep = " ") <--------------
updateTextInput(session = session, "text", value = name)
})
})
))
我应该放什么而不是???????。我已经尝试过input$wordOneButton 和input$action。但结果不是我所期待的。
谢谢!
【问题讨论】: