【发布时间】:2020-06-20 07:04:27
【问题描述】:
我正在尝试使用 HTML 代码更新服务器端的单选按钮列表,但没有成功。
我正在使用这个例子让你了解我想要做什么。我再次提到必须在服务器端,因为我列表中的元素将与用户进行的其他输入相关。
有人可以帮忙弄清楚它是如何制作的吗? 谢谢
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
radioButtons("rb", "Choose one:",
choiceNames = list("icon", "html", "text"),
choiceValues = c(1,2,3)),
textOutput("txt")
)
server <- function(input, output,session) {
a<-HTML("<p style='color:red;'>option2</p>")
list1=as.list(c("option1",a,"option3"))
updateRadioButtons(session, "rb", choiceNames = list1, choiceValues = c(1,2,3))
output$txt <- renderText({
paste("You chose", input$rb)
})
}
shinyApp(ui, server)
}
【问题讨论】: