R flexdashboard 中根本不显示图标

Icons do not show up at all in R flexdashboard

我正在创建一个显示 table 的 flexdashboard。在最后一列中包含图标,但由于 flexdashboard,它们根本不显示。这在 shinydashboard 中正常工作。任何解决方法?

---
title: "Single Column (Fill)"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: fill
---

```{r global, include=FALSE}
library(shiny)
library(shinydashboard)
FCB<-c(5,6,4,6,8)
TWI<-c(3,5,2,3,5)
IN<-c(2,1,1,1,1)
DF1<-data.frame(FCB,TWI,IN)

FCB<-c(0,0,1,2,4)
TWI<-c(1,2,3,4,5)
IN<-c(1,3,4,5,6)
DF2<-data.frame(FCB,TWI,IN)

DF1$direction <- ifelse(
  DF1$FCB < DF2$FCB,
  as.character(icon("angle-up")),
  as.character(icon("angle-down"))
)
```

### Chart 1

```{r}
renderTable(DF1, sanitize.text.function = function(x) x)
```

您正在使用渲染到静态文件的 Shiny 内容。 我将 runtime: shiny 添加到 YAML header。

如果您只需要箭头,可以使用像 these 这样的 simpe UTF-8 箭头吗?

如果您想在 flexdashboard 的 table 中呈现 HTML,您应该使用 DT 包中的数据table。请注意 HTML 的渲染默认情况下是转义的。要在 table 中呈现 HTML,您必须设置 escape = FALSE.

这里有一个选项:

---
title: "Single Column (Fill)"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: fill
  runtime: shiny
---

```{r global, include=FALSE}
library(DT)
library(shiny)
library(shinydashboard)
FCB<-c(5,6,4,6,8)
TWI<-c(3,5,2,3,5)
IN<-c(2,1,1,1,1)
DF1<-data.frame(FCB,TWI,IN)

FCB<-c(0,0,1,2,4)
TWI<-c(1,2,3,4,5)
IN<-c(1,3,4,5,6)
DF2<-data.frame(FCB,TWI,IN)

DF1$direction <- ifelse(
  DF1$FCB < DF2$FCB,
  "<p>&uarr;</p>",
  "<p>&darr;</p>"
  )

DF1.table <- datatable(DF1, escape = FALSE)
```

### Chart 1

```{r}
DT::renderDataTable(DF1.table)
```