The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
This vignette of package
DemographicTable
(CRAN, Github)
presents an idiot-proof interface to create a summary table of simple
statistics, often known as demographic table.
Examples in this vignette require that the search
path
has
library(DemographicTable)
#> Loading required package: flextable
set_flextable_defaults(font.size = 9)
Users may remove the last pipe |> as_flextable()
from
all examples. The author of this package are forced to have it in this
vignette to make package rmarkdown
rendering work.
Data preparation
| tgr |
---|---|
n=60 | |
len. |
|
dose: n (%). |
|
supp: n (%). |
|
| n=60 |
tgr |
group
Color of each group
is determined by
scales::pal_hue()
, which is the default color pallete used
in package ggplot2
.
| tgr | |||
---|---|---|---|---|
n=60 | supp | |||
OJ | VC | Signif | ||
len. |
|
|
| 0.064 |
dose: n (%). |
|
|
| 1.000 |
| n=60 | supp | ||
tgr |
User may choose to hide the \(p\)-values with
compare = FALSE
.
tgr |>
DemographicTable(groups = 'supp', include = c('len', 'dose'), compare = FALSE) |>
as_flextable()
| tgr | ||
---|---|---|---|
n=60 | supp | ||
OJ | VC | ||
len. |
|
|
|
dose: n (%). |
|
|
|
| n=60 | supp | |
tgr |
groups
| tgr | |||||||
---|---|---|---|---|---|---|---|---|
n=60 | supp | dose | ||||||
OJ | VC | Signif1 | 0.5 | 1 | 2 | Signif2 | ||
len. |
|
|
| 0.064 |
|
|
| ★ 0.000; ⸢1⸥ vs. ⸢0.5⸥ |
supp: n (%). |
|
|
| ★ 0.000 |
|
|
| 1.000 |
| n=60 | supp | dose | |||||
tgr |
DemographicTable
stb1 = CO2 |>
DemographicTable(groups = 'Type', include = c('conc', 'uptake'))
tb2 = CO2 |>
subset(subset = (Treatment == 'nonchilled')) |>
DemographicTable(groups = 'Type', include = c('conc', 'uptake'), data.name = 'CO2_nonchilled')
c(tb1, tb2) |> as_flextable()
| CO2 | CO2_nonchilled | ||||||
---|---|---|---|---|---|---|---|---|
n=84 | Type | n=42 | Type | |||||
Quebec | Mississippi | Signif1 | Quebec | Mississippi | Signif2 | |||
conc. |
|
|
| 1.000 |
|
|
| 1.000 |
uptake. |
|
|
| 0.000★ |
|
|
| 0.000★ |
| n=84 | Type | n=42 | Type | ||||
CO2 | CO2_nonchilled |
groups
| MASS::survey | |||
---|---|---|---|---|
n=237 | M.I | |||
Imperial | Metric | Signif | ||
Pulse. | n*=192 | n*=59 | n*=112 | 0.974 |
Fold: n (%). |
|
|
| 0.532 |
| n=237 | M.I | ||
MASS::survey |
logical
valuesUse of logical
values is discouraged, as this practice
is proved confusing to scientists without a strong data background. A
warning message will be printed.
#> Some scientists do not understand logical value (e.g., arm_intervention being TRUE/FALSE)
#> Consider using 2-level factor (e.g., arm being intervention/control)
mtc = mtcars |>
within.data.frame(expr = {
vs = as.logical(vs)
am = as.logical(am)
})
tryCatch(DemographicTable(mtc, groups = 'am', include = c('hp', 'drat')), warning = identity)
#> <simpleWarning in DemographicTable(mtc, groups = "am", include = c("hp", "drat")): Some scientists do not understand logical value (e.g., arm_intervention being TRUE/FALSE)
#> Consider using 2-level factor (e.g., arm being intervention/control)>
tryCatch(DemographicTable(mtc, groups = 'cyl', include = c('vs')), warning = identity)
#> <simpleWarning in FUN(X[[i]], ...): Some scientists do not understand logical value (e.g., arm_intervention being TRUE/FALSE)
#> Consider using 2-level factor (e.g., arm being intervention/control)>
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.