Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display 2 flexdashboard gauges side by side in Rmarkdown HTML?

I have two flexdashboard gauges that I would like to plot side-by-side in an Rmarkdown -> html file. The file is NOT meant to be a flexdashboard, just trying to use the pretty gauges from that package.

---
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)))
```

Aprox Ouput I like big gauges and I cannot lie.

Surprisingly, I'm having a hard time getting them side by side. Tried to use library(gridExtra) but it only likes to arrange things called grobs. Gauges are class htmlwidget & gauge.

Also tried {r out.width=c('500px', '300px'), fig.show='hold'} and cramming them both in the same chunk but got an error.

I'd appreciate any suggestions.

like image 386
Serban Tanasa Avatar asked Nov 16 '25 11:11

Serban Tanasa


1 Answers

The gauges in flexdashboard are specifically for use with the flexdashboard layout system and won't generally work as expected in other formats (that's why the widget is part of flexdashboard rather than in a standalone package).

like image 129
JJ Allaire Avatar answered Nov 19 '25 08:11

JJ Allaire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!