2

我有两个flexdashboard量规,我想在 Rmarkdown -> html 文件中并排绘制。该文件并不意味着是一个 flexdashboard,只是试图使用该包中的漂亮仪表。

---
title: "Eye Gaugeing"
author: "Databot"
date: "10/24/2016"
output: html_document
fig_caption: yes
---

```{r setup, include=FALSE}
library(flexdashboard)
gauge1_data <- 95
gauge2_data <- 63
max_data <- 100
```

## Gauges
```{r gauge, fig.width=2, fig.height=2, fig.cap='Cap1'}
gauge(round(100*(1.0*gauge1_data)/max_data,2),0,100, symbol = '%', label= "Non-Stops: Tile 1", gaugeSectors(
  success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```
```{r gauge2, fig.width=2, fig.height=2, fig.cap='Cap1'}
p0 <- gauge(round(100*(1.0*gauge2_data)/max_data,2),0,100, symbol = '%', label= "Full Cabin Match: Tile 1", gaugeSectors(
  success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```

近似输出 我喜欢大仪表,我不能说谎。

令人惊讶的是,我很难让他们并排。尝试使用library(gridExtra)但它只喜欢安排所谓的东西grobs。仪表是类htmlwidget& gauge

还尝试{r out.width=c('500px', '300px'), fig.show='hold'}将它们都塞进同一个块中,但出现错误。

我会很感激任何建议。

4

2 回答 2

3

flexdashboard 中的仪表专门用于 flexdashboard 布局系统,通常不会在其他格式中按预期工作(这就是为什么小部件是 flexdashboard 的一部分而不是在独立包中的原因)。

于 2016-10-25T01:27:07.550 回答
2

您可以通过使用HTML/Bootstrap 框架创建两列来使仪表并排:

## Gauges

<div class = "row">
<div class = "col-md-6">
<center>
```{r gauge, fig.width=2, fig.height=2}
gauge(round(100*(1.0*gauge1_data)/max_data,2),0,100, symbol = '%', label= "Non-Stops: Tile 1", gaugeSectors(
  success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```
</center>
</div>

<div class = "col-md-6">
<center>    
```{r gauge2, fig.width=2, fig.height=2}
gauge(round(100*(1.0*gauge2_data)/max_data,2),0,100, symbol = '%', label= "Full Cabin Match: Tile 1", gaugeSectors(
  success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```    
</center>
</div>
</div>
于 2019-12-27T21:22:26.693 回答