RMarkdown renderText中文本的条件颜色

时间:2018-02-19 21:56:47

标签: r shiny r-markdown

我试图通过根据R降价表中的条件更改文本的格式(颜色或粗体...)来突出显示文件中的某些错误。我查看了这个主题Conditional font color R Markdown,但是当我在"闪亮的"它需要嵌入到renderText中。所以我尝试了不同的可能性:

```{r}
output$text <- renderText({ 
  if(length(test) > 0) {
    div(paste("There is a value missing line(s):", paste(test[[1]], sep = " ", collapse = " ")), style = "color = red")
  } else {
    "There is no missing value"
  }
})
```

r textOutput('text')`

我也尝试过:

output$text <- renderText({ 
  if(length(test) > 0) {
    paste("**There is a value missing line(s):", paste(test[[1]], sep = " ", collapse = " "), "**"))
  } else {
    "There is no missing value"
  }
})

或那:

output$text <- renderText({ 
  if(length(test) > 0) {
    paste(eval(parse(text = "**")), "There is a value missing line(s):", paste(test[[1]], sep = " ", collapse = " "), eval(parse(text = "**")))
  } else {
    "There is no missing value"
  }
})

output$text <- renderText({ 
  if(length(test) > 0) {
    text.Toprint <- paste("** There is a problem of number of values line(s):", paste(test[[1]], sep = " ", collapse = " "), "**")
    HTML(text.Toprint)
  } else {
    "There is no missing value"
  }
})

最后:

output$text <- renderText({ 
  if(length(test) > 0) {
        text.Toprint <- paste("<b> There is a mistake column. Check the line:", paste(test[[1]], sep = " ", collapse = " "), "</b>")
    HTML(text.Toprint)
  } else {
    "There is no missing value"
  }
})

但他们都没有工作。

您有什么想法或任何文档可以提供建议吗?

非常感谢,晚上好!)

0 个答案:

没有答案