Skip to contents

The returned html object can be immediately used in shiny and rmarkdown.

Usage

as_html(
  x,
  width = NULL,
  class_table = "table table-condensed table-hover",
  class_tr = NULL,
  class_td = NULL,
  class_th = NULL,
  link_label = NULL
)

Arguments

x

rtable object

width

width

class_table

class for table tag

class_tr

class for tr tag

class_td

class for td tag

class_th

class for th tag

link_label

link anchor label (not including tab: prefix) for the table.

Value

A shiny.tag object representing x in HTML.

Examples


tbl <- rtable(
  header = LETTERS[1:3],
  format = "xx",
  rrow("r1", 1,2,3),
  rrow("r2", 4,3,2, indent = 1),
  rrow("r3", indent = 2)
)

as_html(tbl)
#> <div class="rtables-all-parts-block rtables-container">
#>   <table class="table table-condensed table-hover">
#>     <tr>
#>       <th style="white-space:pre;"></th>
#>       <th class="text-center">A</th>
#>       <th class="text-center">B</th>
#>       <th class="text-center">C</th>
#>     </tr>
#>     <tr>
#>       <td class="text-left">r1</td>
#>       <td class="text-center">1</td>
#>       <td class="text-center">2</td>
#>       <td class="text-center">3</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left">r2</td>
#>       <td class="text-center">4</td>
#>       <td class="text-center">3</td>
#>       <td class="text-center">2</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left">r3</td>
#>       <td class="text-center"></td>
#>       <td class="text-center"></td>
#>       <td class="text-center"></td>
#>     </tr>
#>     <caption style="caption-side:top;"><div class="rtables-titles-block rtables-container">
#>         <div class="rtables-main-titles-block rtables-container">
#>           <p class="rtables-main-title"></p>
#>         </div>
#>         <div class="rtables-subtitles-block rtables-container"></div>
#>       </div>
#>     </caption>
#>   </table>
#>   <div class="rtables-footers-block rtables-container"></div>
#> </div>

as_html(tbl, class_table = "table", class_tr = "row")
#> <div class="rtables-all-parts-block rtables-container">
#>   <table class="table">
#>     <tr class="row">
#>       <th style="white-space:pre;"></th>
#>       <th class="text-center">A</th>
#>       <th class="text-center">B</th>
#>       <th class="text-center">C</th>
#>     </tr>
#>     <tr class="row">
#>       <td class="row text-left">r1</td>
#>       <td class="row text-center">1</td>
#>       <td class="row text-center">2</td>
#>       <td class="row text-center">3</td>
#>     </tr>
#>     <tr class="row">
#>       <td class="row text-left">r2</td>
#>       <td class="row text-center">4</td>
#>       <td class="row text-center">3</td>
#>       <td class="row text-center">2</td>
#>     </tr>
#>     <tr class="row">
#>       <td class="row text-left">r3</td>
#>       <td class="row text-center"></td>
#>       <td class="row text-center"></td>
#>       <td class="row text-center"></td>
#>     </tr>
#>     <caption style="caption-side:top;"><div class="rtables-titles-block rtables-container">
#>         <div class="rtables-main-titles-block rtables-container">
#>           <p class="rtables-main-title"></p>
#>         </div>
#>         <div class="rtables-subtitles-block rtables-container"></div>
#>       </div>
#>     </caption>
#>   </table>
#>   <div class="rtables-footers-block rtables-container"></div>
#> </div>

as_html(tbl, class_td = "aaa")
#> <div class="rtables-all-parts-block rtables-container">
#>   <table class="table table-condensed table-hover">
#>     <tr>
#>       <th style="white-space:pre;"></th>
#>       <th class="text-center">A</th>
#>       <th class="text-center">B</th>
#>       <th class="text-center">C</th>
#>     </tr>
#>     <tr>
#>       <td class="text-left">r1</td>
#>       <td class="text-center">1</td>
#>       <td class="text-center">2</td>
#>       <td class="text-center">3</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left">r2</td>
#>       <td class="text-center">4</td>
#>       <td class="text-center">3</td>
#>       <td class="text-center">2</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left">r3</td>
#>       <td class="text-center"></td>
#>       <td class="text-center"></td>
#>       <td class="text-center"></td>
#>     </tr>
#>     <caption style="caption-side:top;"><div class="rtables-titles-block rtables-container">
#>         <div class="rtables-main-titles-block rtables-container">
#>           <p class="rtables-main-title"></p>
#>         </div>
#>         <div class="rtables-subtitles-block rtables-container"></div>
#>       </div>
#>     </caption>
#>   </table>
#>   <div class="rtables-footers-block rtables-container"></div>
#> </div>

if (FALSE) {
Viewer(tbl)
}