Skip to contents

This function is a wraps and extends knitr::kable() to format and print the results of bone microCT comparison analyses at one site by sex for use in an R Markdown document. A code chunk containing this function should probably have the results = "asis" option to allow pretty formatting. Any NA values are printed as an empty string.

Usage

print_results(results, sig_color = "red", ...)

Arguments

results

A list of microCT comparison results, formatted as is the output of compare_groups().

sig_color

What color to print a significant result. Defaults to "red". Set to NULL to disable (and just print everything black).

...

Additional arguments passed on to knitr::kable().

Value

Text output which is by default a Pandoc markdown pipe table for each measure and each sex analyzed. If two sexes are analyzed, Pandoc fenced div syntax is used to print the tables in two columns by sex. For example:

:::: {style="display: flex;"}

::: {}

**BV/TV**

|Sex |Genotype |  n| Mean|  SEM|     P|Sig |
|:---|:--------|--:|----:|----:|-----:|:---|
|M   |Cre      |  3| 18.5| 1.58|      |    |
|M   |Cre;fl   |  3| 19.9| 1.11| 0.701|    |


:::

::: {}

**BV/TV**

|Sex |Genotype |  n| Mean|   SEM|     P|Sig |
|:---|:--------|--:|----:|-----:|-----:|:---|
|F   |Cre      |  3| 18.3| 1.041|      |    |
|F   |Cre;fl   |  3| 17.1| 0.936| 0.656|    |


:::

::::

Examples

gen_key <- read_key_csv(mctr_ex("example-gen-key.csv"))
#> Rows: 12 Columns: 7
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (2): Sex, Genotype
#> dbl (5): AS, SampNo, Spine, Met, Dia
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
gen_trab <- read_trabecular_csv(mctr_ex("example-trabecular.csv"),
                            gen_key)
#> Rows: 24 Columns: 75
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (19): SampName, MeasDate, ListDate, Filename, Site, Energy-I-Code, Contr...
#> dbl (51): SampNo, MeasNo, Integr.Time, Sigma, Support, Threshold, Unit, Data...
#> lgl  (5): S-DOB, S-Remark, Meas-Rmk, RAW-Label, IMA-Label
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
Sp.trab <- gen_trab |> dplyr::filter(Site == "Spine") |> compare_groups()
print_results(Sp.trab)
#> :::: {style="display: flex;"}
#> 
#> ::: {}
#> 
#> **BV/TV**
#> 
#> |Sex |Genotype |  n|     Mean|      SEM|         P|Sig |
#> |:---|:--------|--:|--------:|--------:|---------:|:---|
#> |M   |Cre      |  3| 18.50667| 2.729007|          |    |
#> |M   |Cre;fl   |  3| 19.88333| 1.920498| 0.7010951|    |
#> 
#> 
#> **SMI**
#> 
#> |Sex |Genotype |  n|      Mean|       SEM|         P|Sig |
#> |:---|:--------|--:|---------:|---------:|---------:|:---|
#> |M   |Cre      |  3| 1.2090000| 0.2153279|          |    |
#> |M   |Cre;fl   |  3| 0.7957667| 0.1276412| 0.1741153|    |
#> 
#> 
#> **Tb.N**
#> 
#> |Sex |Genotype |  n|     Mean|       SEM|         P|Sig |
#> |:---|:--------|--:|--------:|---------:|---------:|:---|
#> |M   |Cre      |  3| 3.359600| 0.1352918|          |    |
#> |M   |Cre;fl   |  3| 3.389533| 0.3342937| 0.9378375|    |
#> 
#> 
#> **Tb.Th**
#> 
#> |Sex |Genotype |  n|      Mean|       SEM|         P|Sig |
#> |:---|:--------|--:|---------:|---------:|---------:|:---|
#> |M   |Cre      |  3| 0.0608000| 0.0053678|          |    |
#> |M   |Cre;fl   |  3| 0.0591667| 0.0012863| 0.7820276|    |
#> 
#> 
#> **Tb.Sp**
#> 
#> |Sex |Genotype |  n|      Mean|       SEM|         P|Sig |
#> |:---|:--------|--:|---------:|---------:|---------:|:---|
#> |M   |Cre      |  3| 0.2971333| 0.0092326|          |    |
#> |M   |Cre;fl   |  3| 0.2987667| 0.0317294| 0.9629486|    |
#> 
#> 
#> :::
#> 
#> ::: {}
#> 
#> **BV/TV**
#> 
#> |Sex |Genotype |  n|     Mean|      SEM|         P|Sig |
#> |:---|:--------|--:|--------:|--------:|---------:|:---|
#> |F   |Cre      |  3| 18.27333| 1.803416|          |    |
#> |F   |Cre;fl   |  3| 17.11000| 1.621121| 0.6564675|    |
#> 
#> 
#> **SMI**
#> 
#> |Sex |Genotype |  n|      Mean|       SEM|         P|Sig |
#> |:---|:--------|--:|---------:|---------:|---------:|:---|
#> |F   |Cre      |  3| 0.9251667| 0.0829199|          |    |
#> |F   |Cre;fl   |  3| 0.8524667| 0.1574138| 0.7037516|    |
#> 
#> 
#> **Tb.N**
#> 
#> |Sex |Genotype |  n|     Mean|       SEM|         P|Sig |
#> |:---|:--------|--:|--------:|---------:|---------:|:---|
#> |F   |Cre      |  3| 6.650367| 3.8016284|          |    |
#> |F   |Cre;fl   |  3| 3.046233| 0.2479679| 0.4432629|    |
#> 
#> 
#> **Tb.Th**
#> 
#> |Sex |Genotype |  n|      Mean|       SEM|       P|Sig |
#> |:---|:--------|--:|---------:|---------:|-------:|:---|
#> |F   |Cre      |  3| 0.0532000| 0.0041789|        |    |
#> |F   |Cre;fl   |  3| 0.0579333| 0.0012979| 0.34024|    |
#> 
#> 
#> **Tb.Sp**
#> 
#> |Sex |Genotype |  n|      Mean|       SEM|        P|Sig |
#> |:---|:--------|--:|---------:|---------:|--------:|:---|
#> |F   |Cre      |  3| 0.2866333| 0.0982075|         |    |
#> |F   |Cre;fl   |  3| 0.3354667| 0.0314189| 0.660476|    |
#> 
#> 
#> :::
#> 
#> ::::
#>