| Title: | Create Elegant Table 1 in HTML/'LaTeX' for Bio-Statistics |
| Version: | 2.2.0 |
| Description: | Creates the "table one" of bio-medical papers. Fill it with your data and the name of the variable which you'll make the group(s) out of and it will make univariate and bivariate analysis, and parse the result into an HTML or 'LaTeX' table ready to paste into a paper. |
| License: | GPL (≥ 3) |
| Encoding: | UTF-8 |
| Language: | en-US |
| Imports: | dplyr, kableExtra, methods, parallel, purrr, stats, tibble, tidyr |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/tiago972/doudpackage |
| BugReports: | https://github.com/tiago972/doudpackage/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-25 13:09:35 UTC; mac |
| Author: | Edouard Baudouin |
| Maintainer: | Edouard Baudouin <edouardpierre.baudouin@aphp.fr> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-25 14:10:12 UTC |
S4 class initialization function
Description
Initialization function for Var initialize,Var-method()
Usage
Var(name, type = "", normal = TRUE)
Arguments
name |
A character taking name of the variable |
type |
A character taking name of the variable type |
normal |
Logical, if variable, is numeric; is it normal |
Value
Var Object
S4 class
Description
A S4 class containing name, type and normality assessment of variable
Slots
nameA character taking name of the variable
typeA character taking name of the variable type
normalLogical, if variable, is numeric; is it normal
S4 class
Description
A S4 class containing Var initialize,Var-method() It also contains the pvalue, the parsed value
the missing values and the group for which it was calculated
Slots
group_varThe subgroup for which proportions, mean/sd were calculated and missing values
pvalueThe calculated pvalue
parsed_nameThe name of the variable parsed with the n (%), mean (SD)
valueThe values calculated parsed
missing.valueMissing values numbers and proportions n (%)
missing.value.nameMissing values concatenate with the level of the variable if it factor
Method to access S4 Var elements
Description
Method to modify Var elements by name
Usage
## S4 replacement method for signature 'Var'
x[i] <- value
Arguments
x |
: object |
i |
: Element name |
value |
: Value to be added |
Value
object
Method to access S4 Var elements
Description
Method to modify VarGroup initialize,VarGroup-method() elements by name
Usage
## S4 replacement method for signature 'VarGroup'
x[i] <- value
Arguments
x |
Object |
i |
Element name |
value |
Value to be added |
Value
object
Method to modify S4 Var elements
Description
Method to modify parseClass initialize,parseClass-method() elements by name
Usage
## S4 replacement method for signature 'parseClass'
x[i] <- value
Arguments
x |
: Object |
i |
: Element name |
value |
: Value to be added |
Value
parseClass Object
Method to access S4 Var elements
Description
Method to access Var elements by name
Usage
## S4 method for signature 'Var'
x[i]
Arguments
x |
: object |
i |
: value |
Value
object of Var
Method to access S4 Var elements
Description
Method to access VarGroup initialize,VarGroup-method() elements by name
Usage
## S4 method for signature 'VarGroup'
x[i]
Arguments
x |
: object |
i |
: value |
Value
object element
Method to access S4 Var elements
Description
Method to access parseClass initialize,parseClass-method() elements by name
Usage
## S4 method for signature 'parseClass'
x[i]
Arguments
x |
: Object |
i |
: Element name |
Value
object
anaBiv generic function
Description
Generic function of anaBiv which gives bivariate analysis according to group
Usage
anaBiv(var, group, parallel, ...)
Arguments
var |
listVar object or data.frame |
group |
Name of the factor variable to make subgroups with |
parallel |
Logical. Make analysis using parallel from |
... |
Further arguments: |
Value
A list of VarGroup object or data.frame
anaBiv data.frame function
Description
Generic function of anaBiv which gives bivariate analysis according to group
Usage
## S4 method for signature 'data.frame,character'
anaBiv(var, group, parallel, normality = "normal", digits.p = 3L, ...)
Arguments
var |
listVar object or data.frame |
group |
Name of the factor variable to make subgroups with |
parallel |
Logical. Make analysis using parallel from |
normality |
One of "normal", "non normal" or "assess", as in |
digits.p |
Integer. Significant digits for p value. |
... |
Further arguments: |
Value
A list of VarGroup object or data.frame
Examples
# A small simulated clinical trial
set.seed(42)
n <- 200
patients <- data.frame(
arm = factor(sample(c("Placebo", "Treatment"), n, replace = TRUE)),
age = round(rnorm(n, mean = 65, sd = 10)),
crp = round(rlnorm(n, meanlog = 2, sdlog = 1), 1),
sex = factor(sample(c("Female", "Male"), n, replace = TRUE)),
diabetes = factor(sample(c("No", "Yes"), n, replace = TRUE, prob = c(0.7, 0.3))),
nyha = factor(sample(c("I", "II", "III", "IV"), n, replace = TRUE),
ordered = TRUE)
)
patients$crp[sample(n, 15)] <- NA
# p values only, without the descriptive table
res <- anaBiv(patients, group = "arm", parallel = FALSE, normality = "assess")
data.frame(variable = sapply(res, function(x) x["name"]),
pvalue = sapply(res, function(x) x["pvalue"]))
anaBiv data.frame function
Description
Generic function of anaBiv which gives bivariate analysis according to group
Usage
## S4 method for signature 'listVar,character'
anaBiv(var, group, parallel, ...)
Arguments
var |
listVar object or data.frame |
group |
Name of the factor variable to make subgroups with |
parallel |
Logical. Make analysis using parallel from |
... |
Further arguments: |
Value
A list of VarGroup object or data.frame
Create a table of descriptive analysis of a dataset
Description
Displays together the univariate analysis (mean/median; SD/IQR; proportions)
and the bivariate analysis (t test/Wilcoxon, ANOVA/Kruskal-Wallis, Chi2 or
Fisher) of every variable of a dataset. The univariate analysis can be
sub-grouped by a variable of interest of n levels; the test applied to each
variable follows from its type and from normality.
Usage
descTab(
data,
group = "",
quanti = TRUE,
quali = TRUE,
na.print = FALSE,
pvalue = TRUE,
digits.p = 3L,
digits.qt = 1L,
digits.ql = 1L,
normality = "normal",
parallel = FALSE,
mc.cores = 0
)
Arguments
data |
A dataset. Needs to be a data.frame or a tibble. |
group |
Optional. The name of the factor variable to make sub-groups
comparisons with; it must have at least two non empty levels. Omitted,
|
quanti, quali, na.print, pvalue |
Logical. If false, won't display
quantitative/qualitative/Missing values/pvalues variable results. |
digits.p |
Integer. Significant digits for p value |
digits.qt |
Integer. Significant digits for mean/median, SD/IQR |
digits.ql |
Integer. Significant digits for proportions |
normality |
One of "normal", "non normal" or "assess". "normal" applies the parametric tests (mean (SD), t test/ANOVA) to every quantitative variable, "non normal" the non parametric ones (median (IQR), Wilcoxon/Kruskal-Wallis), and "assess" decides variable by variable with a Shapiro-Wilk test at the 5% level. |
parallel |
Logical. Make analysis using parallel from |
mc.cores |
If parallel is TRUE, how many cores to use. The default, 0, uses all the cores but one. |
Details
Only numeric, integer and factor (including ordered factor) variables are
described. A variable of any other type is ignored with a warning, as is a
variable whose test cannot be computed: its p value is then NA and the rest
of the table is still produced.
Value
An S4 object of class parseClass. Its ["table"] element is a
data.frame (whether or not there is a group, and also when data is a
tibble) with a var column, one column per level of group, a Total
column and, if there is a group and pvalue = TRUE, a pvalue column.
See Also
parseClassFun() to turn the result into an HTML/LaTeX table.
Examples
# A small simulated clinical trial
set.seed(42)
n <- 200
patients <- data.frame(
arm = factor(sample(c("Placebo", "Treatment"), n, replace = TRUE)),
age = round(rnorm(n, mean = 65, sd = 10)),
crp = round(rlnorm(n, meanlog = 2, sdlog = 1), 1),
sex = factor(sample(c("Female", "Male"), n, replace = TRUE)),
diabetes = factor(sample(c("No", "Yes"), n, replace = TRUE, prob = c(0.7, 0.3))),
nyha = factor(sample(c("I", "II", "III", "IV"), n, replace = TRUE),
ordered = TRUE)
)
patients$crp[sample(n, 15)] <- NA
# Compare the two arms. With normality = "assess", age (normal) is described
# by mean (SD) with a t test, crp (skewed) by median (IQR) with a Wilcoxon test
tab <- descTab(patients, group = "arm", normality = "assess", na.print = TRUE)
tab["table"]
# No group: a single Total column, no test
descTab(patients)["table"]
# Quantitative variables only, two decimals
descTab(patients, group = "arm", quali = FALSE, digits.qt = 2)["table"]
# Render it (see parseClassFun() for the layout options)
parseClassFun(tab)
This function is depreciated, please use anaBiv(). anaBiv()
Description
This function is depreciated, please use anaBiv(). anaBiv()
Usage
ft_ana_biv(...)
Arguments
... |
None |
Value
No return value, depreciated
This function is depreciated, please use anaBiv(). descTab()
Description
This function is depreciated, please use anaBiv(). descTab()
Usage
ft_desc_tab(...)
Arguments
... |
None |
Value
No return value, depreciated
This function is depreciated, please use parseClassFun()
Description
This function is depreciated, please use parseClassFun()
Usage
ft_parse(...)
Arguments
... |
None |
Value
No return value, depreciated
S4 class initialization function
Description
Initialization function for Var initialize,Var-method()
Usage
## S4 method for signature 'Var'
initialize(.Object, name, type, normal)
Arguments
.Object |
Object to be initialized |
name |
A character taking name of the variable |
type |
A character taking name of the variable type |
normal |
Logical, if variable, is numeric; is it normal |
Value
Var Object
S4 class initialization function
Description
Initialization function for VarGroup initialize,VarGroup-method()
Usage
## S4 method for signature 'VarGroup'
initialize(
.Object,
x,
group_var,
pvalue,
parsed_name,
value,
missing.value,
missing.value.name
)
Arguments
.Object |
Object to be initialized |
x |
A Var object |
group_var |
The subgroup for which proportions, mean/sd were calculated and missing values |
pvalue |
The calculated pvalue |
parsed_name |
The name of the variable parsed with the n (%), mean (SD) |
value |
The values calculated parsed |
missing.value |
Missing values numbers and proportions n (%) |
missing.value.name |
Missing values concatenate with the level of the variable if it factor |
Value
VarGroup object
S4 class initialization function
Description
Initialization function for parseClass object initialize,parseClass-method()
Usage
## S4 method for signature 'parseClass'
initialize(
.Object,
table,
group,
pvalue,
na.print,
quanti,
quali,
var_list,
data,
digits.qt,
digits.ql
)
Arguments
.Object |
The object to create |
table |
The result of descTab |
group |
The variable from which to make subgroups |
pvalue, na.print, quanti, quali |
Values from descTab |
var_list |
An object of listVar |
data |
The dataset provided in descTab |
digits.qt, digits.ql |
As provided in descTab |
Value
parseClass object
S4 class
Description
A class of list of Var object
Slots
Lista list of Var
S4 class initialization function
Description
Initialization function for parseClass object initialize,parseClass-method()
Usage
parseClass(
table,
group,
pvalue,
na.print,
quanti,
quali,
var_list,
data,
digits.qt,
digits.ql
)
Arguments
table |
The result of descTab |
group |
The variable from which to make subgroups |
pvalue, na.print, quanti, quali |
Values from descTab |
var_list |
An object of listVar |
data |
The dataset provided in descTab |
digits.qt, digits.ql |
As provided in descTab |
Value
parseClass object
S4 class
Description
A S4 class containing all the information needed for parsClassFun the missing values and the group for which it was calculated
Slots
tableThe result of descTab
groupThe variable from which to make subgroups
pvalue,na.print,quanti,qualiValues from descTab
descTab()var_listAn object of listVar
listVar-class()dataThe dataset provided in descTab
digits.qt,digits.qlAs provided in descTab
Make the LaTeX/HTML table. Generic function
Description
Make the LaTeX/HTML table. Generic function
Usage
parseClassFun(
table,
col.order = NULL,
levels_to_keep = NULL,
group_rows_labels = NULL,
font = "arial"
)
Arguments
table |
|
col.order |
Optional. A vector containing the column order. If set, must contain at least all levels of group, without duplicates. Three columns created are "var", "Total", and "pvalue" which can be present in the vector |
levels_to_keep |
Optional, named list. If the variable is binary, which level to keep. Default is the last level of levels(variable). Must be as: list("variable name" = "level to keep"). |
group_rows_labels |
Optional, named list. Create row labels in order to regroup them. Must be as list("label" = c("var1", "var2"), "label2" = c("var3", "var4")). Variable names are matched exactly, and a variable with no row in the table is an error. Rows are reordered to follow the order of the labels and of the variables within each label. |
font |
The HTML font of the table. Default "arial". |
Value
An HTML/LaTex file which can be used directly in Rmarkdown and copy paste
See Also
descTab() which produces the object this function renders.
Examples
# A small simulated clinical trial
set.seed(42)
n <- 200
patients <- data.frame(
arm = factor(sample(c("Placebo", "Treatment"), n, replace = TRUE)),
age = round(rnorm(n, mean = 65, sd = 10)),
crp = round(rlnorm(n, meanlog = 2, sdlog = 1), 1),
sex = factor(sample(c("Female", "Male"), n, replace = TRUE)),
diabetes = factor(sample(c("No", "Yes"), n, replace = TRUE, prob = c(0.7, 0.3))),
nyha = factor(sample(c("I", "II", "III", "IV"), n, replace = TRUE),
ordered = TRUE)
)
patients$crp[sample(n, 15)] <- NA
tab <- descTab(patients, group = "arm", normality = "assess", na.print = TRUE)
# Default layout
parseClassFun(tab)
# One line for the binary variables, rows grouped under labels, the Total
# column after the arms, and a custom font
parseClassFun(
tab,
levels_to_keep = list(sex = "Female", diabetes = "Yes"),
group_rows_labels = list("Demographics" = c("age", "sex"),
"Clinical" = c("crp", "diabetes", "nyha")),
col.order = c("var", "Placebo", "Treatment", "Total", "pvalue"),
font = "Times New Roman"
)
Make the LaTeX/HTML table
Description
This functions takes the S4 output of descTab to create an HTML parsed table
Usage
## S4 method for signature 'parseClass'
parseClassFun(
table,
col.order = NULL,
levels_to_keep = NULL,
group_rows_labels = NULL,
font = "arial"
)
Arguments
table |
|
col.order |
Optional. A vector containing the column order. If set, must contain at least all levels of group, without duplicates. Three columns created are "var", "Total", and "pvalue" which can be present in the vector |
levels_to_keep |
Optional, named list. If the variable is binary, which level to keep. Default is the last level of levels(variable). Must be as: list("variable name" = "level to keep"). |
group_rows_labels |
Optional, named list. Create row labels in order to regroup them. Must be as list("label" = c("var1", "var2"), "label2" = c("var3", "var4")). Variable names are matched exactly, and a variable with no row in the table is an error. Rows are reordered to follow the order of the labels and of the variables within each label. |
font |
The HTML font of the table. Default "arial". |
Value
An HTML/LaTex file which can be used directly in Rmarkdown and copy paste
See Also
descTab() which produces the object this function renders.
Examples
# A small simulated clinical trial
set.seed(42)
n <- 200
patients <- data.frame(
arm = factor(sample(c("Placebo", "Treatment"), n, replace = TRUE)),
age = round(rnorm(n, mean = 65, sd = 10)),
crp = round(rlnorm(n, meanlog = 2, sdlog = 1), 1),
sex = factor(sample(c("Female", "Male"), n, replace = TRUE)),
diabetes = factor(sample(c("No", "Yes"), n, replace = TRUE, prob = c(0.7, 0.3))),
nyha = factor(sample(c("I", "II", "III", "IV"), n, replace = TRUE),
ordered = TRUE)
)
patients$crp[sample(n, 15)] <- NA
tab <- descTab(patients, group = "arm", normality = "assess", na.print = TRUE)
# Default layout
parseClassFun(tab)
# One line for the binary variables, rows grouped under labels, the Total
# column after the arms, and a custom font
parseClassFun(
tab,
levels_to_keep = list(sex = "Female", diabetes = "Yes"),
group_rows_labels = list("Demographics" = c("age", "sex"),
"Clinical" = c("crp", "diabetes", "nyha")),
col.order = c("var", "Placebo", "Treatment", "Total", "pvalue"),
font = "Times New Roman"
)