如何停止在闪亮输出中重复粘贴功能?
How to stop paste function repeating in shiny output?
我想在 select 输入中选择多个选项并将它们显示为输出而不重复词干。在这个例子中,我希望看到
You chose NY NJ CT
而不是
You chose NY You chose NJ You chose CT
如何阻止粘贴功能重复“您选择的”?
这是 shiny 应用程序的代码:
## Only run examples in interactive R sessions
if (interactive()) {
# demoing group support in the `choices` arg
shinyApp(
ui = fluidPage(
sidebarPanel(
selectInput("state", "Choose a state:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
multiple = TRUE
)),
mainPanel(
textOutput("result")
)
),
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}
难道你只需要改变粘贴功能的位置吗?
即:print("you choose", paste(input$state))
感谢 user12728748,此解决方案有效:
paste("You chose", paste(input$state, collapse = ", "))
我想在 select 输入中选择多个选项并将它们显示为输出而不重复词干。在这个例子中,我希望看到
You chose NY NJ CT
而不是
You chose NY You chose NJ You chose CT
如何阻止粘贴功能重复“您选择的”?
这是 shiny 应用程序的代码:
## Only run examples in interactive R sessions
if (interactive()) {
# demoing group support in the `choices` arg
shinyApp(
ui = fluidPage(
sidebarPanel(
selectInput("state", "Choose a state:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
multiple = TRUE
)),
mainPanel(
textOutput("result")
)
),
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}
难道你只需要改变粘贴功能的位置吗?
即:print("you choose", paste(input$state))
感谢 user12728748,此解决方案有效:
paste("You chose", paste(input$state, collapse = ", "))