This is the primary function of mypdf1, with her you can make tables in HTML or LaTeX format, the main idea is to provide minimal parameters to create their own table, so you necessarily only need to provide a data.frame
Arguments
- obj
Object used to create the table.
data.frame
,list
or environment (or object coercible byas.data.frame
to adata.frame
)- title
Title for the table, write in string format
- format
Format of table, write in string format. Possible values are
"latex"
, "html
".- code
If you want the table code to appear in the console, put
code = TRUE
, you can combine withformat
.- tabs
If you want a row separator inside table, put
tabs = FALSE
.- full_page
If you want the table not to take up the full width of the page, put
full_page = FALSE
.- ...
Other arguments
Note
Remember that by default the format is "html"
The default of code
is FALSE
The default of tabs
is TRUE
The default of full_page
is TRUE
The value of format
will be automatically determined if the function is called within a knitr document
Examples
iris %>%
dplyr::group_by(Species) %>%
dplyr::summarise(mean = mean(Sepal.Length)) %>%
mypdf1::pdf1_tbl("THIS FUNCTION IS SO INCREDIBLE!")
#> <table class=" lightable-classic" style='font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;'>
#> <caption>THIS FUNCTION IS SO INCREDIBLE!</caption>
#> <thead>
#> <tr>
#> <th style="text-align:center;"> Species </th>
#> <th style="text-align:center;"> mean </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:center;"> setosa </td>
#> <td style="text-align:center;"> 5.006 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> versicolor </td>
#> <td style="text-align:center;"> 5.936 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> virginica </td>
#> <td style="text-align:center;"> 6.588 </td>
#> </tr>
#> </tbody>
#> </table>
mtcars |>
dplyr::group_by(carb) |>
dplyr::summarise(sd = sd(wt)) |>
mypdf1::pdf1_tbl()
#> <table class=" lightable-classic" style='font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;'>
#> <caption></caption>
#> <thead>
#> <tr>
#> <th style="text-align:center;"> carb </th>
#> <th style="text-align:center;"> sd </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:center;"> 1 </td>
#> <td style="text-align:center;"> 0.6214499 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> 2 </td>
#> <td style="text-align:center;"> 0.8269761 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> 3 </td>
#> <td style="text-align:center;"> 0.1835756 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> 4 </td>
#> <td style="text-align:center;"> 1.0536001 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> 6 </td>
#> <td style="text-align:center;"> NA </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> 8 </td>
#> <td style="text-align:center;"> NA </td>
#> </tr>
#> </tbody>
#> </table>