Skip to contents

[Experimental]

This function makes cross tables, like all functions from mypdf1 you need to supply a data.frame, and in this case two variables.

Usage

pdf1_cross_tbl(obj, var1, var2, title = "", marg = FALSE)

Arguments

obj

Object used to create the table. Data frame, list, or environment (or object coercible by as.data.frame to a data frame)

var1

Variable that you want the table (not written in string format)

var2

Variable that you want on the top of the table (not written in string format)

title

title for the table, write in string format

marg

Marginal row table, default is FALSE

Value

A knitr_kable with 2x2 table fitted

Examples

mtcars |>
  mypdf1::pdf1_cross_tbl(cyl, am, "title", marg = TRUE)
#> <table class=" lightable-classic" style='font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;'>
#> <caption>title</caption>
#>  <thead>
#> <tr>
#> <th style="empty-cells: hide;" colspan="1"></th>
#> <th style="padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2"><div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">am</div></th>
#> </tr>
#>   <tr>
#>    <th style="text-align:center;"> cyl </th>
#>    <th style="text-align:center;"> 0 </th>
#>    <th style="text-align:center;"> 1 </th>
#>   </tr>
#>  </thead>
#> <tbody>
#>   <tr>
#>    <td style="text-align:center;"> 4 </td>
#>    <td style="text-align:center;"> 0.2727273 </td>
#>    <td style="text-align:center;"> 0.7272727 </td>
#>   </tr>
#>   <tr>
#>    <td style="text-align:center;"> 6 </td>
#>    <td style="text-align:center;"> 0.5714286 </td>
#>    <td style="text-align:center;"> 0.4285714 </td>
#>   </tr>
#>   <tr>
#>    <td style="text-align:center;"> 8 </td>
#>    <td style="text-align:center;"> 0.8571429 </td>
#>    <td style="text-align:center;"> 0.1428571 </td>
#>   </tr>
#> </tbody>
#> </table>