test_that('print_table1', {
mtcars_summaries <-
list('Miles Per Gallon' =
list('min' = ~ min(mpg),
'mean' = ~ mean(mpg),
'mean ± sd' = ~ qwraps2::mean_sd(mpg),
'max' = ~ max(mpg)),
'Weight' =
list('median' = ~ median(wt)),
'Cylinders' =
list('4 cyl: n (%)' = ~ qwraps2::n_perc0(cyl == 4),
'6 cyl: n (%)' = ~ qwraps2::n_perc0(cyl == 6),
'8 cyl: n (%)' = ~ qwraps2::n_perc0(cyl == 8)))
expect_equal(as.character(print_table1(
summary_table = qwraps2::summary_table(mtcars, mtcars_summaries),
title = '**summary table markdown**',
caption = 'example using mtcars')),
'**summary table markdown**
|covariates |mtcars (N = 32) |
|:-----------------------------|:-------------------|
|**Miles Per Gallon** | |
| min |10.4 |
| mean |20.09062 |
| mean ± sd |20.09 ± 6.03 |
| max |33.9 |
|**Weight** | |
| median |3.325 |
|**Cylinders** | |
| 4 cyl: n (%) |11 (34) |
| 6 cyl: n (%) |7 (22) |
| 8 cyl: n (%) |14 (44) |
example using mtcars')
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.