How to add percent, dollar, euro and other currency signs to valueBox in R flexdashboard

Here we will use the package ‘scales’ in order to add any symbol including percentage sign, dollar sign, euro sign etc… to your valueBoxes in your flexdashboard. So let us show an example of a dashboard together with its code.

Percentage Sign Currency Symbols valueBox

The following is the code that generates such a dashboard.

---
title: "Signs and Symbols in valueBox"
output: 
  flexdashboard::flex_dashboard:
    orientation: row
---

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

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

### As Percentage
```{r}
valueBox(scales::percent(0.231), icon = "fa-line-chart",col="orange")
```

### Amount in Dollars
```{r}
valueBox(scales::dollar(0.231), icon = "fa-bank",col="green")
```

### Euro Symbol
```{r}
euro <- dollar_format(prefix="\u20ac",suffix = "")
valueBox(euro(100.30), icon = "fa-briefcase",col="blue")
```

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

### Sterling Symbol
```{r}
euro <- dollar_format(prefix="\u00A3",suffix = "")
valueBox(euro(100.30), icon = "fa-pencil",col="green")
```

### Euro Symbol at the end
```{r}
euro <- dollar_format(prefix = "",suffix="\u20ac")
valueBox(euro(340.30), icon = "fa-money",col="blue")
```

### Amount in Euro
```{r}
euro <- dollar_format(prefix = "\u20ac",suffix="")
valueBox(euro(354030), icon = "fa-bank",col="orange")
```

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

### Adding Text
```{r}
Withtext <- dollar_format(prefix = "",suffix=" days")
valueBox(Withtext(35), icon = "fa-calendar",col="blue")
```

### Adding Text
```{r}
Withtext <- dollar_format(prefix = "",suffix="USD")
valueBox(Withtext(353), icon = "fa-bank",col="red")
```

### In Million Form
```{r}
MillionForm <- dollar_format(prefix = "$",suffix="M")
valueBox(MillionForm(3.25), icon = "fa-money",col="green")
```

Notes:

First of all, make sure that you have the package ‘scales’ installed. For the percentage sign, the package ‘scales’ has a built-in function ‘percent()’ which presents the decimal in percentage form. For amounts in dollars, this package has a built-in function ‘dollar()’ that attaches the dollar symbol to the number. For all the remaining signs and symbols, this package has the function ‘dollar_format(prefix,suffix)’ that lets you define the text, sign or symbol that is prepended and/or appended to the value in your valueBox.