I have a datatable such as this one :
library(stringi)
library(tidyverse)
library(data.table)
MWE <-
data.table("Zone"=stri_rand_strings(9, 10, pattern = "[A-Za-z0-9]")) %>%
.[,paste0("Var",2:11):= round(rnorm(9,2,4),1)]
From that I want to output a nice table. I have managed to do something satisfying through the gt
package, but I am opn to switch if necessary
library(gt)
MWE_Table <- gt(MWE)%>%
tab_spanner(label="PIB", columns = c(2:7))%>%
tab_spanner(label="IPC", columns = c(8:11))%>%
tab_style(
style = list(
cell_text(weight = "lighter", style="italic")),
locations = cells_body(columns = c("Var3","Var5","Var7","Var9","Var11"))) %>%
tab_style(
style = list(
cell_text(weight = "normal", style="italic")),
locations = cells_body(columns = c("Var3","Var5","Var7","Var9","Var11"),rows = (Zone == "France"))) %>%
cols_label(Zone="",
Var2=Annee1, Var3="(rev)",
Var4=Annee2, Var5="(rev)",
Var6="Cumul", Var7="(rev)",
Var8=paste0(" ",Annee1), Var9="(rev)",
Var10=Annee2, Var11="(rev)")%>%
cols_align(., align = c("center"), columns = c(2:11)) %>%
tab_header(
title = md(paste("Title ")),
subtitle = md("Subtitle")
)
Which gives me the following table :
I would like to export is as a vector graphic, but the metafile option that I usually use is not listed as an option :
- Can I do something to add this option ?
- If it is that
gt
does not support it, which alternative to produce tables exists that allows to export as a metafile ?