r - 如何添加标题和换行符?

标签 r r-markdown flexdashboard

我使用带有行布局的 flexdashboard 创建了一个仪表板。我的第一行包括值框,第二行是传单 map 。如何在第二行上方添加标题?

如下面的代码所示,我在第二行下使用了 ### Map 标题,但它呈现为小标题(在输出中显示)。有没有办法:

  1. 在两行之间添加换行符?
  2. 要将标题格式设置为增大字体大小并加粗?

title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    smooth_scroll: true
---
<br><br><br>


```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
```

Row
-----------------------------------------------------------------------

### Articles per Day

```{r}
valueBox("5 articles", icon = "fa-pencil")
```

### Comments per Day

```{r}
valueBox("10 comments", icon = "fa-comments")
```
Row
-----------------------------------------------------------------------

### Map
```{r}
m <- leaflet() %>%
    addTiles() %>%  
    setView(lng=-77.030137, lat=38.902986, zoom = 16) %>%
    addMarkers(lng=-77.030137, lat=38.902986, popup="<b>Hello</b><br><a href='https://www.washingtonpost.com'>-Me</a>")

m 
```

输出:

enter image description here

最佳答案

您可以增加字体大小并加粗标题### Map,具体来说,您可以通过使用CSS类(例如.custom)来定位它并应用.chart-title 类的 CSS 规则。

要在值框和 map 之间创建空间,一种选择是增加上边距。

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    smooth_scroll: true
---
<br><br><br>


```{css, echo=FALSE}
.custom {
  margin-top: 30px;
}

.custom .chart-title{
  font-size: 30px;
  font-weight: bold;
}

```


```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
```

Row
-----------------------------------------------------------------------

### Articles per Day

```{r}
valueBox("5 articles", icon = "fa-pencil")
```

### Comments per Day

```{r}
valueBox("10 comments", icon = "fa-comments")
```



Row
-----------------------------------------------------------------------
### Map {.custom}


```{r}
m <- leaflet() %>%
    addTiles() %>%  
    setView(lng=-77.030137, lat=38.902986, zoom = 16) %>%
    addMarkers(lng=-77.030137, lat=38.902986, popup="<b>Hello</b><br><a href='https://www.washingtonpost.com'>-Me</a>")

m 
```

flex dashboard with large and bold header


关于r - 如何添加标题和换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73788937/

相关文章:

r - Rmarkdown 中的循环 : How to make an in-text figure reference? 图标题?

css - 删除 <span> 和 <list> 条目之间的垂直空间

r - 使用 knit kable 功能对齐列

r - 未识别的空白

r - 使用 dplyr 自举置信区间

r - 将节点集合的邻居名称提取为列表

r - Flexdashboard:为### 标题设置 anchor (级别 3)

R Knitr :kable - How to display table without column names?

r - 用串扰过滤两个表

html - rvest 和 NHL 统计数据的 Css 选择器问题