to_gt() converts a procr_table object into a gt::gt() table, handling
header generation, spanner creation from row/column varformats, number
formatting, and metadata (title, subtitle, stubhead, footer). to_html()
wraps to_gt() and renders the result as a standalone HTML string via
gt::as_raw_html().
Arguments
- tab
A
procr_tableobject.- ...
Not used for values, forces later arguments to bind by name.
- inline_css
Use inline CSS
scalar<logical>// default:TRUEAn option to supply styles to table elements as inlined CSS styles. This is useful when including the table HTML as part of an HTML email message body, since inlined styles are largely supported in email clients over using CSS in a
<style>block.- show_unit
Logical. If
TRUE(default) and units have been set viaset_data_unit(), units are displayed in a separate row below the column header.
Value
to_gt() returns a gt object representing the table. to_html()
returns a character string containing its HTML representation.
Examples
region_f <- new_format_asis(eusilc, region)
gender_f <- new_format_asis(eusilc, gender)
tab <- create_table_mean(eusilc, region_f ~ gender_f, var = eqIncome)
to_gt(tab)
#> Error in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/usr/local/lib/R/site-library/V8/libs/V8.so':
#> libnode.so.109: cannot open shared object file: No such file or directory
to_html(tab)
#> <div id="eexombwkke" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
#> <style>#eexombwkke table {
#> font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
#> -webkit-font-smoothing: antialiased;
#> -moz-osx-font-smoothing: grayscale;
#> }
#>
#> #eexombwkke thead, #eexombwkke tbody, #eexombwkke tfoot, #eexombwkke tr, #eexombwkke td, #eexombwkke th {
#> border-style: none;
#> }
#>
#> #eexombwkke p {
#> margin: 0;
#> padding: 0;
#> }
#>
#> #eexombwkke .gt_table {
#> display: table;
#> border-collapse: collapse;
#> line-height: normal;
#> margin-left: auto;
#> margin-right: auto;
#> color: #333333;
#> font-size: 16px;
#> font-weight: normal;
#> font-style: normal;
#> background-color: #FFFFFF;
#> width: auto;
#> border-top-style: solid;
#> border-top-width: 2px;
#> border-top-color: #A8A8A8;
#> border-right-style: none;
#> border-right-width: 2px;
#> border-right-color: #D3D3D3;
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #A8A8A8;
#> border-left-style: none;
#> border-left-width: 2px;
#> border-left-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_caption {
#> padding-top: 4px;
#> padding-bottom: 4px;
#> }
#>
#> #eexombwkke .gt_title {
#> color: #333333;
#> font-size: 125%;
#> font-weight: initial;
#> padding-top: 4px;
#> padding-bottom: 4px;
#> padding-left: 5px;
#> padding-right: 5px;
#> border-bottom-color: #FFFFFF;
#> border-bottom-width: 0;
#> }
#>
#> #eexombwkke .gt_subtitle {
#> color: #333333;
#> font-size: 85%;
#> font-weight: initial;
#> padding-top: 3px;
#> padding-bottom: 5px;
#> padding-left: 5px;
#> padding-right: 5px;
#> border-top-color: #FFFFFF;
#> border-top-width: 0;
#> }
#>
#> #eexombwkke .gt_heading {
#> background-color: #FFFFFF;
#> text-align: center;
#> border-bottom-color: #FFFFFF;
#> border-left-style: none;
#> border-left-width: 1px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 1px;
#> border-right-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_bottom_border {
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_col_headings {
#> border-top-style: solid;
#> border-top-width: 2px;
#> border-top-color: #D3D3D3;
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> border-left-style: none;
#> border-left-width: 1px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 1px;
#> border-right-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_col_heading {
#> color: #333333;
#> background-color: #FFFFFF;
#> font-size: 100%;
#> font-weight: normal;
#> text-transform: inherit;
#> border-left-style: none;
#> border-left-width: 1px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 1px;
#> border-right-color: #D3D3D3;
#> vertical-align: bottom;
#> padding-top: 5px;
#> padding-bottom: 6px;
#> padding-left: 5px;
#> padding-right: 5px;
#> overflow-x: hidden;
#> }
#>
#> #eexombwkke .gt_column_spanner_outer {
#> color: #333333;
#> background-color: #FFFFFF;
#> font-size: 100%;
#> font-weight: normal;
#> text-transform: inherit;
#> padding-top: 0;
#> padding-bottom: 0;
#> padding-left: 4px;
#> padding-right: 4px;
#> }
#>
#> #eexombwkke .gt_column_spanner_outer:first-child {
#> padding-left: 0;
#> }
#>
#> #eexombwkke .gt_column_spanner_outer:last-child {
#> padding-right: 0;
#> }
#>
#> #eexombwkke .gt_column_spanner {
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> vertical-align: bottom;
#> padding-top: 5px;
#> padding-bottom: 5px;
#> overflow-x: hidden;
#> display: inline-block;
#> width: 100%;
#> }
#>
#> #eexombwkke .gt_spanner_row {
#> border-bottom-style: hidden;
#> }
#>
#> #eexombwkke .gt_group_heading {
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> color: #333333;
#> background-color: #FFFFFF;
#> font-size: 100%;
#> font-weight: initial;
#> text-transform: inherit;
#> border-top-style: solid;
#> border-top-width: 2px;
#> border-top-color: #D3D3D3;
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> border-left-style: none;
#> border-left-width: 1px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 1px;
#> border-right-color: #D3D3D3;
#> vertical-align: middle;
#> text-align: left;
#> }
#>
#> #eexombwkke .gt_empty_group_heading {
#> padding: 0.5px;
#> color: #333333;
#> background-color: #FFFFFF;
#> font-size: 100%;
#> font-weight: initial;
#> border-top-style: solid;
#> border-top-width: 2px;
#> border-top-color: #D3D3D3;
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> vertical-align: middle;
#> }
#>
#> #eexombwkke .gt_from_md > :first-child {
#> margin-top: 0;
#> }
#>
#> #eexombwkke .gt_from_md > :last-child {
#> margin-bottom: 0;
#> }
#>
#> #eexombwkke .gt_row {
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> margin: 10px;
#> border-top-style: solid;
#> border-top-width: 1px;
#> border-top-color: #D3D3D3;
#> border-left-style: none;
#> border-left-width: 1px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 1px;
#> border-right-color: #D3D3D3;
#> vertical-align: middle;
#> overflow-x: hidden;
#> }
#>
#> #eexombwkke .gt_stub {
#> color: #333333;
#> background-color: #FFFFFF;
#> font-size: 100%;
#> font-weight: initial;
#> text-transform: inherit;
#> border-right-style: solid;
#> border-right-width: 2px;
#> border-right-color: #D3D3D3;
#> padding-left: 5px;
#> padding-right: 5px;
#> }
#>
#> #eexombwkke .gt_stub_row_group {
#> color: #333333;
#> background-color: #FFFFFF;
#> font-size: 100%;
#> font-weight: initial;
#> text-transform: inherit;
#> border-right-style: solid;
#> border-right-width: 2px;
#> border-right-color: #D3D3D3;
#> padding-left: 5px;
#> padding-right: 5px;
#> vertical-align: top;
#> }
#>
#> #eexombwkke .gt_row_group_first td {
#> border-top-width: 2px;
#> }
#>
#> #eexombwkke .gt_row_group_first th {
#> border-top-width: 2px;
#> }
#>
#> #eexombwkke .gt_summary_row {
#> color: #333333;
#> background-color: #FFFFFF;
#> text-transform: inherit;
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> }
#>
#> #eexombwkke .gt_first_summary_row {
#> border-top-style: solid;
#> border-top-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_first_summary_row.thick {
#> border-top-width: 2px;
#> }
#>
#> #eexombwkke .gt_last_summary_row {
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_grand_summary_row {
#> color: #333333;
#> background-color: #FFFFFF;
#> text-transform: inherit;
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> }
#>
#> #eexombwkke .gt_first_grand_summary_row {
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> border-top-style: double;
#> border-top-width: 6px;
#> border-top-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_last_grand_summary_row_top {
#> padding-top: 8px;
#> padding-bottom: 8px;
#> padding-left: 5px;
#> padding-right: 5px;
#> border-bottom-style: double;
#> border-bottom-width: 6px;
#> border-bottom-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_striped {
#> background-color: rgba(128, 128, 128, 0.05);
#> }
#>
#> #eexombwkke .gt_table_body {
#> border-top-style: solid;
#> border-top-width: 2px;
#> border-top-color: #D3D3D3;
#> border-bottom-style: solid;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_footnotes {
#> color: #333333;
#> background-color: #FFFFFF;
#> border-bottom-style: none;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> border-left-style: none;
#> border-left-width: 2px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 2px;
#> border-right-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_footnote {
#> margin: 0px;
#> font-size: 90%;
#> padding-top: 4px;
#> padding-bottom: 4px;
#> padding-left: 5px;
#> padding-right: 5px;
#> }
#>
#> #eexombwkke .gt_sourcenotes {
#> color: #333333;
#> background-color: #FFFFFF;
#> border-bottom-style: none;
#> border-bottom-width: 2px;
#> border-bottom-color: #D3D3D3;
#> border-left-style: none;
#> border-left-width: 2px;
#> border-left-color: #D3D3D3;
#> border-right-style: none;
#> border-right-width: 2px;
#> border-right-color: #D3D3D3;
#> }
#>
#> #eexombwkke .gt_sourcenote {
#> font-size: 90%;
#> padding-top: 4px;
#> padding-bottom: 4px;
#> padding-left: 5px;
#> padding-right: 5px;
#> }
#>
#> #eexombwkke .gt_left {
#> text-align: left;
#> }
#>
#> #eexombwkke .gt_center {
#> text-align: center;
#> }
#>
#> #eexombwkke .gt_right {
#> text-align: right;
#> font-variant-numeric: tabular-nums;
#> }
#>
#> #eexombwkke .gt_font_normal {
#> font-weight: normal;
#> }
#>
#> #eexombwkke .gt_font_bold {
#> font-weight: bold;
#> }
#>
#> #eexombwkke .gt_font_italic {
#> font-style: italic;
#> }
#>
#> #eexombwkke .gt_super {
#> font-size: 65%;
#> }
#>
#> #eexombwkke .gt_footnote_marks {
#> font-size: 75%;
#> vertical-align: 0.4em;
#> position: initial;
#> }
#>
#> #eexombwkke .gt_asterisk {
#> font-size: 100%;
#> vertical-align: 0;
#> }
#>
#> #eexombwkke .gt_indent_1 {
#> text-indent: 5px;
#> }
#>
#> #eexombwkke .gt_indent_2 {
#> text-indent: 10px;
#> }
#>
#> #eexombwkke .gt_indent_3 {
#> text-indent: 15px;
#> }
#>
#> #eexombwkke .gt_indent_4 {
#> text-indent: 20px;
#> }
#>
#> #eexombwkke .gt_indent_5 {
#> text-indent: 25px;
#> }
#>
#> #eexombwkke .katex-display {
#> display: inline-flex !important;
#> margin-bottom: 0.75em !important;
#> }
#>
#> #eexombwkke div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
#> height: 0px !important;
#> }
#> </style>
#> <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
#> <thead>
#> <tr class="gt_col_headings">
#> <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="a::stub">region</th>
#> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="male">male</th>
#> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1" scope="col" id="female">female</th>
#> </tr>
#> </thead>
#> <tbody class="gt_table_body">
#> <tr><th id="stub_1_1" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Burgenland</th>
#> <td headers="stub_1_1 male" class="gt_row gt_right">23 208 </td>
#> <td headers="stub_1_1 female" class="gt_row gt_right">21 464 </td></tr>
#> <tr><th id="stub_1_2" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Lower Austria</th>
#> <td headers="stub_1_2 male" class="gt_row gt_right">20 823 </td>
#> <td headers="stub_1_2 female" class="gt_row gt_right">19 348 </td></tr>
#> <tr><th id="stub_1_3" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Vienna</th>
#> <td headers="stub_1_3 male" class="gt_row gt_right">20 538 </td>
#> <td headers="stub_1_3 female" class="gt_row gt_right">19 478 </td></tr>
#> <tr><th id="stub_1_4" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Carinthia</th>
#> <td headers="stub_1_4 male" class="gt_row gt_right">20 617 </td>
#> <td headers="stub_1_4 female" class="gt_row gt_right">19 198 </td></tr>
#> <tr><th id="stub_1_5" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Styria</th>
#> <td headers="stub_1_5 male" class="gt_row gt_right">20 660 </td>
#> <td headers="stub_1_5 female" class="gt_row gt_right">18 885 </td></tr>
#> <tr><th id="stub_1_6" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Upper Austria</th>
#> <td headers="stub_1_6 male" class="gt_row gt_right">21 289 </td>
#> <td headers="stub_1_6 female" class="gt_row gt_right">19 859 </td></tr>
#> <tr><th id="stub_1_7" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Salzburg</th>
#> <td headers="stub_1_7 male" class="gt_row gt_right">21 535 </td>
#> <td headers="stub_1_7 female" class="gt_row gt_right">19 483 </td></tr>
#> <tr><th id="stub_1_8" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Tyrol</th>
#> <td headers="stub_1_8 male" class="gt_row gt_right">19 887 </td>
#> <td headers="stub_1_8 female" class="gt_row gt_right">18 285 </td></tr>
#> <tr><th id="stub_1_9" scope="row" class="gt_row gt_left gt_stub" style="vertical-align: top;">Vorarlberg</th>
#> <td headers="stub_1_9 male" class="gt_row gt_right">21 874 </td>
#> <td headers="stub_1_9 female" class="gt_row gt_right">21 058 </td></tr>
#> </tbody>
#>
#> </table>
#> </div>