Using this as a reference from SOen , I arrived to the following:
First of all, evaluate well if you really want to do this. Text and formatting are much more flexible and easier to modify than an image.
A simple way to do what you want is to use the gridExtra
package:
library("gridExtra")
dat <- matrix(c(1000, 100, 10000, 10000,3.145,1700.42), 2)
grid.table(dat)
Result:
Thetableranoutoftitlesbecauseitisanarraywithnocolnames
.Youcancustomizetheimage,butthesyntaxisnotsosimple.Toseewhatcanbedone,youneedtoinvestigatethedefaultthemevalues:
>ttheme_default()$core$core$fg_fun...$core$fg_params$core$fg_params$parse[1]FALSE$core$fg_params$col[1]"black"
$core$fg_params$fontsize
[1] 12
...
You can customize the theme as follows:
mytheme <- ttheme_default()
mytheme$core$bg_params$fill <- c("yellow", "pink")
grid.table(dat, theme = mytheme)
That would lead to this result:
If you really want to invest in this, take a look at the help ( ?grid.table
) and default theme to see what can be modified.