formattable is package by Kun Ren that makes formatting pretty tables in RMarkdown very easy!
slidify is a package by Ramnath Vaidyanathan that makes making HTML slides in RMarkdown easy to make!
Here, I'm trying to use the two together...
Data come from my engsoccerdata package - these are summary stats for EPL teams 1992-2014 that played at least 400 games.
## Source: local data frame [17 x 8]
##
## team gp wins losses draws points ppg winpct
## 1 Manchester United 848 547 126 175 1816 2.14 0.65
## 2 Arsenal 848 460 167 221 1601 1.89 0.54
## 3 Chelsea 848 448 185 215 1559 1.84 0.53
## 4 Liverpool 848 422 213 213 1479 1.74 0.50
## 5 Tottenham Hotspur 848 336 293 219 1227 1.45 0.40
## 6 Everton 848 309 297 242 1169 1.38 0.36
## 7 Aston Villa 848 303 286 259 1168 1.38 0.36
## 8 Newcastle United 768 303 267 198 1107 1.44 0.39
## 9 Blackburn Rovers 696 262 250 184 970 1.39 0.38
## 10 Manchester City 658 261 232 165 948 1.44 0.40
## 11 West Ham United 692 225 292 175 850 1.23 0.33
## 12 Leeds United 468 189 154 125 692 1.48 0.40
## 13 Southampton 582 174 246 162 684 1.18 0.30
## 14 Middlesbrough 536 160 220 156 636 1.19 0.30
## 15 Fulham 494 150 208 136 586 1.19 0.30
## 16 Bolton Wanderers 494 149 217 128 575 1.16 0.30
## 17 Sunderland 494 131 239 124 517 1.05 0.27
| team | gp | wins | losses | draws | points | ppg | winpct |
|---|---|---|---|---|---|---|---|
| Manchester United | 848 | 547 | 126 | 175 | 1816 | 2.14 | 0.65 |
| Arsenal | 848 | 460 | 167 | 221 | 1601 | 1.89 | 0.54 |
| Chelsea | 848 | 448 | 185 | 215 | 1559 | 1.84 | 0.53 |
| Liverpool | 848 | 422 | 213 | 213 | 1479 | 1.74 | 0.5 |
| Tottenham Hotspur | 848 | 336 | 293 | 219 | 1227 | 1.45 | 0.4 |
| Everton | 848 | 309 | 297 | 242 | 1169 | 1.38 | 0.36 |
| Aston Villa | 848 | 303 | 286 | 259 | 1168 | 1.38 | 0.36 |
| Newcastle United | 768 | 303 | 267 | 198 | 1107 | 1.44 | 0.39 |
| Blackburn Rovers | 696 | 262 | 250 | 184 | 970 | 1.39 | 0.38 |
| Manchester City | 658 | 261 | 232 | 165 | 948 | 1.44 | 0.4 |
| West Ham United | 692 | 225 | 292 | 175 | 850 | 1.23 | 0.33 |
| Leeds United | 468 | 189 | 154 | 125 | 692 | 1.48 | 0.4 |
| Southampton | 582 | 174 | 246 | 162 | 684 | 1.18 | 0.3 |
| Middlesbrough | 536 | 160 | 220 | 156 | 636 | 1.19 | 0.3 |
| Fulham | 494 | 150 | 208 | 136 | 586 | 1.19 | 0.3 |
| Bolton Wanderers | 494 | 149 | 217 | 128 | 575 | 1.16 | 0.3 |
| Sunderland | 494 | 131 | 239 | 124 | 517 | 1.05 | 0.27 |
library(formattable)
formattable(myt400, list(
winpct = formatter("span", style = function(x)
style(color = ifelse(x > quantile(x, 0.75), "mediumblue", NA))),
gp = formatter("span", style = function(x)
style("font-weight" = ifelse(x == 848, "bold", NA))),
points = formatter("span", style = function(x, m = 1 - x/max(x) * 0.8, ms = round(1-m))
style("display" = "block", "border-radius" = "4px", "background-color" = rgb(0, m, 0),
"padding-right" = "4px", "color" = rgb(1,1,1))),
ppg = formatter("span", style = function(x, m = 1-x/max(x), ms = round(1-m))
style("display" = "block", "border-radius" = "4px", "padding-right" = "4px",
"background-color" = rgb(m, m, 0), "color" = rgb(ms,ms,ms)))))
Also, I wrapped the R code chunk in <small> tags