Title: | Creating Demographic Table |
---|---|
Description: | Functions for creating demographic table of simple summary statistics and comparison(s) over one or more groups. Returned value is printed via package 'flextable'. |
Authors: | Tingting Zhan [aut, cre, cph]
|
Maintainer: | Tingting Zhan <[email protected]> |
License: | GPL-2 |
Version: | 0.1.10 |
Built: | 2025-02-18 06:43:43 UTC |
Source: | https://github.com/cran/DemographicTable |
Functions for creating demographic table with simple summary statistics, with optional comparison(s) over one or more groups.
Numeric variables are summarized in means, standard deviations, medians, inter-quartile-ranges (IQR),
skewness, Shapiro-Wilk normality test and ranges, and compared using two-sample -test,
Wilcoxon test, ANOVA and/or Kruskal-Wallis test.
Logical and factor variables are summarized in counts and percentages and
compared using chi-squared test and/or Fisher's exact test.
Returned value is printed via package flextable.
Maintainer: Tingting Zhan [email protected] (ORCID) [copyright holder]
Create a demographic table with simple summary statistics, with optional comparison(s) over one or more groups.
DemographicTable( data, data.name = substitute(data), groups = NULL, exclude = NULL, exclude_rx, include, include_rx, paired = FALSE, robust = TRUE, overall = TRUE, compare = TRUE, pairwise = 3L, ... )
DemographicTable( data, data.name = substitute(data), groups = NULL, exclude = NULL, exclude_rx, include, include_rx, paired = FALSE, robust = TRUE, overall = TRUE, compare = TRUE, pairwise = 3L, ... )
data |
|
data.name |
character scalar, or the argument call of |
groups |
character scalar or vector,
the name(s) of sub-group(s) for which the summary statistics are provided.
Default |
exclude |
character vector,
the name(s) of variable(s) to be excluded.
Default |
exclude_rx |
(optional) regex, pattern of the names of the variable(s) to be excluded. |
include |
character vector,
the name(s) of variable(s) to be included.
Default |
include_rx |
(optional) regex, pattern of the names of the variable(s) to be included. |
paired |
logical scalar, whether to perform paired test (default |
robust |
logical scalar.
If |
overall |
logical scalar.
If |
compare |
logical scalar.
If |
pairwise |
integer scalar,
minimum number of groups where pairwise comparisons need to be performed.
Default |
... |
additional parameters, currently not in use |
A demographic table with simple summary statistics, with optional comparison(s) over one or more groups, is created.
numeric variables are summarized in means, standard deviations, medians, inter-quartile-ranges (IQR),
skewness, -value of Shapiro-Wilk normality test and ranges.
If
group
is specified, they are compared using two-sample t.test,
wilcox.test (Wilcoxon / Mann-Whitney), one-way aov (ANOVA) and/or
kruskal.test (Kruskal-Wallis).
logical and factor variables are summarized in counts and percentages.
If group
is specified, they are compared using prop.test (chi-squared)
and/or fisher.test (Fisher's exact).
Function DemographicTable returns an object of S3 class 'DemographicTable'
,
which is a list of matrix-es.
tgr = within(ToothGrowth, expr = { dose = factor(dose) }) DemographicTable(tgr, include = c('supp', 'len', 'dose')) DemographicTable(tgr, groups = 'supp', include = c('len', 'dose')) DemographicTable(tgr, groups = 'supp', include = 'len', paired = TRUE) DemographicTable(tgr, groups = 'supp', include = 'len', compare = FALSE) DemographicTable(tgr, groups = c('supp', 'dose'), include = 'len') (tb1 = DemographicTable(CO2, groups = 'Type', include = c('conc', 'uptake'))) CO2_nonchilled = subset(CO2, Treatment == 'nonchilled') (tb2 = DemographicTable(CO2_nonchilled, groups = 'Type', include = c('conc', 'uptake'))) c(tb1, tb2) # pairwise comparision DemographicTable(MASS::survey, groups = 'Fold') # missing value in `groups` DemographicTable(MASS::survey, groups = c('M.I'))
tgr = within(ToothGrowth, expr = { dose = factor(dose) }) DemographicTable(tgr, include = c('supp', 'len', 'dose')) DemographicTable(tgr, groups = 'supp', include = c('len', 'dose')) DemographicTable(tgr, groups = 'supp', include = 'len', paired = TRUE) DemographicTable(tgr, groups = 'supp', include = 'len', compare = FALSE) DemographicTable(tgr, groups = c('supp', 'dose'), include = 'len') (tb1 = DemographicTable(CO2, groups = 'Type', include = c('conc', 'uptake'))) CO2_nonchilled = subset(CO2, Treatment == 'nonchilled') (tb2 = DemographicTable(CO2_nonchilled, groups = 'Type', include = c('conc', 'uptake'))) c(tb1, tb2) # pairwise comparision DemographicTable(MASS::survey, groups = 'Fold') # missing value in `groups` DemographicTable(MASS::survey, groups = c('M.I'))