library(gapminder)
library(dplyr)
library(tidyr)
library(stringr)
library(purrr)
library(gt)
library(mmtable2)
# devtools::install()
You can combine tables with +
, /
and *
operators.
The +
operator places tables side-by-side (sharing headers)
ex1 <- t1 + t2
print(ex1)
Table 1 | Table 2 | ||||||||
GDP | Population | ||||||||
1992 | 1997 | 2002 | 2007 | 1992 | 1997 | 2002 | 2007 | ||
Asia | Kuwait | 34.9 | 40.3 | 35.1 | 47.3 | 1.4 | 1.8 | 2.1 | 2.5 |
Singapore | 24.8 | 33.5 | 36.0 | 47.1 | 3.2 | 3.8 | 4.2 | 4.6 |
The /
operator places tables on top of one another (sharing headers)
ex2 <- t1 / t3
print(ex2)
GDP | ||||||
1992 | 1997 | 2002 | 2007 | |||
Table 1 | Asia | Kuwait | 34.9 | 40.3 | 35.1 | 47.3 |
Singapore | 24.8 | 33.5 | 36.0 | 47.1 | ||
Table 3 | Oceania | Australia | 23.4 | 27.0 | 30.7 | 34.4 |
New Zealand | 18.4 | 21.1 | 23.2 | 25.2 |
The *
operator “integrates” tables
ex3 <- t1 * t3 * t4 * t2
print(ex3)
GDP | Population | ||||||||
1992 | 1997 | 2002 | 2007 | 1992 | 1997 | 2002 | 2007 | ||
Asia | Kuwait | 34.9 | 40.3 | 35.1 | 47.3 | 1.4 | 1.8 | 2.1 | 2.5 |
Singapore | 24.8 | 33.5 | 36.0 | 47.1 | 3.2 | 3.8 | 4.2 | 4.6 | |
Oceania | Australia | 23.4 | 27.0 | 30.7 | 34.4 | 17.5 | 18.6 | 19.5 | 20.4 |
New Zealand | 18.4 | 21.1 | 23.2 | 25.2 | 3.4 | 3.7 | 3.9 | 4.1 |