gt object as RTF — as_rtf" />

Get the RTF content from a gt_tbl object as as a single-element character vector. This object can be used with writeLines() to generate a valid .rtf file that can be opened by RTF readers.

as_rtf(data)

Arguments

data

a table object that is created using the gt() function.

See also

Other table export functions: as_latex, as_raw_html, extract_summary

Examples

# Use `gtcars` to create a gt table; # add a header and then export as # RTF code tab_rtf <- gtcars %>% dplyr::select(mfr, model) %>% dplyr::slice(1:2) %>% gt() %>% tab_header( title = md("Data listing from **gtcars**"), subtitle = md("`gtcars` is an R dataset") ) %>% as_rtf() # `tab_rtf` is a single element character # vector tab_rtf %>% cat()
#> {\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf400 #> {\fonttbl\f0\fswiss\fcharset0 Helvetica;} #> {\colortbl;\red255\green255\blue255; #> } #> {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;\cssrgb\c37036\c37036\c37036;\csgray\c0\c0; #> } #> \deftab20 #> \cf0 #> \itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrr\brdrnil #> \clmgf \clvertalb \clshdrawnil \clheight340 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt100 \gaph\cellx935 #> \clmrg \clvertalb \clshdrawnil \clheight340 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt100 \gaph\cellx1870 #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \f0\fs36 \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Data listing from **gtcars** #> \fs24 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell #> \pard\intbl\itap1\cell #> \row #> #> \itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil #> \clmgf \clvertalc \clshdrawnil \clheight240 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadb100 \gaph\cellx935 #> \clmrg \clvertalc \clshdrawnil \clheight240 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadb100 \gaph\cellx1870 #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> #> \fs20 \expnd0\expndtw0\kerning0\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 `gtcars` is an R dataset #> \fs28 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell\pard\intbl\itap1\cell #> \row\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil #> \clvertalc \clshdrawnil \clheight520 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \gaph\cellx935 #> \clvertalc \clshdrawnil \clheight520 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \gaph\cellx1870 #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 mfr \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 model \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell #> \row\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil #> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx935 #> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx1870 #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Ford \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 GT \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell #> \row\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil #> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx935 #> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx1870 #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Ferrari \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell #> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 #> \expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 458 Speciale \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0\expnd0\expndtw0\kerning0 #> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 \cell \lastrow\row}