【发布时间】:2016-01-27 16:19:12
【问题描述】:
我希望 Shiny 根据矢量的大小打印出一些不同颜色的文本。我在想这样的事情:
output$some_text <- renderText({
if(length(some_vec) < 20){
paste("This is red text")
<somehow make it red>
}else{
paste("This is blue text")
<somehow make it blue>
...但后来我意识到,我是在服务器中执行此操作,而不是 UI。
而且,据我所知,我无法将此条件逻辑移到 UI 中。
例如,这样的内容在 UI 中不起作用:
if(length(some_vec)< 20){
column(6, tags$div(
HTML(paste("This text is ", tags$span(style="color:red", "red"), sep = ""))
)}
else{
tags$div(HTML(paste("This text is ", tags$span(style="color:blue", "blue"), sep = ""))
)}
有人有什么创意吗?
【问题讨论】: