Print bone microCT data
print_data.Rd
This is a wrapper around knitr::kable()
to print out bone microCT
data 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 set to allow for pretty formatting.
Arguments
- data
A data frame containing bone microCT data, formatted as is the output of
read_trabecular_csv()
,read_cortical_csv()
, orread_mfe_csv()
(orread_*_excel()
).- ...
Additional arguments passed on to
knitr::kable()
.
Value
Text output which by default is a Pandoc markdown pipe table for each
sex contained in the data
supplied. For example:
| AS|Sex |Genotype | BV/TV| SMI| Tb.N| Tb.Th| Tb.Sp|
|----:|:---|:--------|-----:|----:|----:|-----:|-----:|
| 1365|M |Cre | 5.43| 3.23| 2.46| 0.062| 0.412|
| 1370|M |Cre | 6.39| 3.01| 2.59| 0.060| 0.373|
| 1422|M |Cre | 8.65| 2.95| 2.81| 0.072| 0.351|
| 1369|M |Cre;fl | 12.53| 2.44| 3.33| 0.066| 0.286|
| 1420|M |Cre;fl | 6.58| 3.39| 2.68| 0.072| 0.353|
| 1421|M |Cre;fl | 14.70| 1.79| 3.23| 0.070| 0.302|
| AS|Sex |Genotype | BV/TV| SMI| Tb.N| Tb.Th| Tb.Sp|
|----:|:---|:--------|-----:|----:|----:|-----:|-----:|
| 1366|F |Cre | 4.47| 3.73| 2.67| 0.059| 0.371|
| 1372|F |Cre | 1.33| 4.40| 1.55| 0.074| 0.666|
| 1373|F |Cre | 2.27| 3.36| 2.69| 0.036| 0.373|
| 1367|F |Cre;fl | 0.23| 4.17| 1.79| 0.034| 0.558|
| 1368|F |Cre;fl | 0.77| 4.08| 2.10| 0.040| 0.482|
| 1371|F |Cre;fl | 1.62| 3.43| 1.86| 0.039| 0.527|
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.
print_data(gen_trab |> dplyr::filter(Site == "Met"))
#>
#>
#> | AS|Sex |Genotype | BV/TV| SMI| Tb.N| Tb.Th| Tb.Sp|
#> |----:|:---|:--------|-----:|------:|------:|------:|------:|
#> | 1365|M |Cre | 5.43| 3.2274| 2.4599| 0.0620| 0.4123|
#> | 1370|M |Cre | 6.39| 3.0104| 2.5933| 0.0604| 0.3729|
#> | 1422|M |Cre | 8.65| 2.9501| 2.8148| 0.0718| 0.3511|
#> | 1369|M |Cre;fl | 12.53| 2.4409| 3.3321| 0.0658| 0.2862|
#> | 1420|M |Cre;fl | 6.58| 3.3896| 2.6769| 0.0719| 0.3533|
#> | 1421|M |Cre;fl | 14.70| 1.7908| 3.2276| 0.0700| 0.3020|
#>
#>
#>
#>
#> | AS|Sex |Genotype | BV/TV| SMI| Tb.N| Tb.Th| Tb.Sp|
#> |----:|:---|:--------|-----:|------:|------:|------:|------:|
#> | 1366|F |Cre | 4.47| 3.7246| 2.6656| 0.0593| 0.3709|
#> | 1372|F |Cre | 1.33| 4.4028| 1.5515| 0.0741| 0.6656|
#> | 1373|F |Cre | 2.27| 3.3563| 2.6863| 0.0359| 0.3728|
#> | 1367|F |Cre;fl | 0.23| 4.1722| 1.7888| 0.0337| 0.5579|
#> | 1368|F |Cre;fl | 0.77| 4.0806| 2.0950| 0.0400| 0.4821|
#> | 1371|F |Cre;fl | 1.62| 3.4308| 1.8633| 0.0386| 0.5275|
#>
#>