diff --git a/CHANGELOG.md b/CHANGELOG.md
index a07d664..d97a955 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Unreleased
+- Added single-argument method to `table_one` which summarizes all columns in the passed table except those used for grouping [#48](https://github.com/PumasAI/SummaryTables.jl/pull/48).
- Fixed issue with using `missing` as a group in `table_one`. This PR also removes redundant group totals if there's just one subgroup to do a total over [#47](https://github.com/PumasAI/SummaryTables.jl/pull/47).
## 3.0.0 - 2024-09-23
diff --git a/docs/src/predefined_tables/table_one.md b/docs/src/predefined_tables/table_one.md
index 09b2109..9d9298d 100644
--- a/docs/src/predefined_tables/table_one.md
+++ b/docs/src/predefined_tables/table_one.md
@@ -9,7 +9,7 @@ Optionally, there can be grouping applied along the columns as well.
In this example, several variables of a hypothetical population are analyzed split by sex.
-```@example
+```@example table_one_intro
using SummaryTables
using DataFrames
@@ -28,6 +28,15 @@ table_one(
)
```
+You can also omit the second argument as a shortcut when you quickly want to summarize all columns of your dataset. The columns in `groupby` are excluded automatically:
+
+```@example table_one_intro
+table_one(
+ data,
+ groupby = :blood_type,
+)
+```
+
## Argument 1: `table`
The first argument can be any object that is a table compatible with the `Tables.jl` API.
@@ -64,12 +73,14 @@ data = [(; x = 1, y = "4"), (; x = 2, y = "5"), (; x = 3, y = "6")]
table_one(data, [:x, :y])
```
-## Argument 2: `analyses`
+## Optional argument 2: `analyses`
The second argument takes a vector specifying analyses, with one entry for each "row section" of the resulting table.
If only one analysis is passed, the vector can be omitted.
Each analysis can have up to three parts: the variable, the analysis function and the label.
+For convenience, if the `analyses` argument is omitted, it is equivalent to passing `Tables.columnnames(table)` except that all columns referenced in `groupby` are filtered out.
+
The variable is passed as a `Symbol`, corresponding to a column in the input data, and must always be specified.
The other two parts are optional.
diff --git a/src/table_one.jl b/src/table_one.jl
index 5021a88..b86b943 100644
--- a/src/table_one.jl
+++ b/src/table_one.jl
@@ -518,6 +518,19 @@ function table_one(
Table(cells, header_offset-1, nothing; celltable_kws...)
end
+"""
+ table_one(table; kwargs...)
+
+Create a `table_one` with with all columns from `table` except those used in the `groupby` keyword.
+"""
+function table_one(table; groupby = [], kwargs...)
+ groups = make_groups(groupby)
+ groupsyms = [g.symbol for g in groups]
+ all_names = Tables.columnnames(table)
+ all_names_but_groups = setdiff(all_names, groupsyms)
+ return table_one(table, all_names_but_groups; groupby, kwargs...)
+end
+
tableone_column_header() = CellStyle(halign = :center, bold = true)
tableone_column_header_spanned() = CellStyle(halign = :center, bold = true, border_bottom = true)
tableone_column_header_key() = CellStyle(; halign = :center)
diff --git a/test/references/table_one/single_arg.docx.txt b/test/references/table_one/single_arg.docx.txt
new file mode 100644
index 0000000..c523281
--- /dev/null
+++ b/test/references/table_one/single_arg.docx.txt
@@ -0,0 +1,951 @@
+############################## [Content_Types].xml ##############################
+
+
+
+
+
+
+
+
+
+############################## _rels/.rels ##############################
+
+
+
+
+############################## word/_rels/document.xml.rels ##############################
+
+
+
+
+############################## word/styles.xml ##############################
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+############################## word/document.xml ##############################
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Total
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ value1
+
+
+
+
+
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
+
+
+
+
+
+
+
+ c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ d
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ e
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/references/table_one/single_arg.latex.txt b/test/references/table_one/single_arg.latex.txt
new file mode 100644
index 0000000..110d739
--- /dev/null
+++ b/test/references/table_one/single_arg.latex.txt
@@ -0,0 +1,34 @@
+\documentclass{article}
+\usepackage{threeparttable}
+\usepackage{multirow}
+\usepackage{booktabs}
+\begin{document}
+\begin{table}[!ht]
+\setlength\tabcolsep{0pt}
+\centering
+\begin{threeparttable}
+\begin{tabular}{@{\extracolsep{2ex}}*{2}{lc}}
+\toprule
+ & \textbf{Total} \\
+\midrule
+\textbf{value1} & \\
+\hspace{12.0pt}Mean (SD) & 4.5 (2.45) \\
+\hspace{12.0pt}Median [Min, Max] & 4.5 [1, 8] \\
+\textbf{value2} & \\
+\hspace{12.0pt}a & 3 (37.5\%) \\
+\hspace{12.0pt}b & 3 (37.5\%) \\
+\hspace{12.0pt}c & 2 (25\%) \\
+\textbf{group1} & \\
+\hspace{12.0pt}a & 4 (50\%) \\
+\hspace{12.0pt}b & 4 (50\%) \\
+\textbf{group3} & \\
+\hspace{12.0pt}c & 4 (50\%) \\
+\hspace{12.0pt}d & 4 (50\%) \\
+\textbf{group2} & \\
+\hspace{12.0pt}e & 4 (50\%) \\
+\hspace{12.0pt}f & 4 (50\%) \\
+\bottomrule
+\end{tabular}
+\end{threeparttable}
+\end{table}
+\end{document}
\ No newline at end of file
diff --git a/test/references/table_one/single_arg.txt b/test/references/table_one/single_arg.txt
new file mode 100644
index 0000000..3827ed6
--- /dev/null
+++ b/test/references/table_one/single_arg.txt
@@ -0,0 +1,101 @@
+
+
+ |
+
+ |
+ Total |
+
+ |
+ value1 |
+ |
+
+
+ Mean (SD) |
+ 4.5 (2.45) |
+
+
+ Median [Min, Max] |
+ 4.5 [1, 8] |
+
+
+ value2 |
+ |
+
+
+ a |
+ 3 (37.5%) |
+
+
+ b |
+ 3 (37.5%) |
+
+
+ c |
+ 2 (25%) |
+
+
+ group1 |
+ |
+
+
+ a |
+ 4 (50%) |
+
+
+ b |
+ 4 (50%) |
+
+
+ group3 |
+ |
+
+
+ c |
+ 4 (50%) |
+
+
+ d |
+ 4 (50%) |
+
+
+ group2 |
+ |
+
+
+ e |
+ 4 (50%) |
+
+
+ f |
+ 4 (50%) |
+
+ |
+
\ No newline at end of file
diff --git a/test/references/table_one/single_arg.typ.txt b/test/references/table_one/single_arg.typ.txt
new file mode 100644
index 0000000..6a1bf04
--- /dev/null
+++ b/test/references/table_one/single_arg.typ.txt
@@ -0,0 +1,45 @@
+
+#table(
+ rows: 17,
+ columns: 2,
+ column-gutter: 0.25em,
+ align: (left, center),
+ stroke: none,
+ table.hline(y: 0, stroke: 1pt),
+ [],
+ [*Total*],
+ table.hline(y: 1, stroke: 0.75pt),
+ [*value1*],
+ [],
+ [#h(12.0pt)Mean (SD)],
+ [4.5 (2.45)],
+ [#h(12.0pt)Median [Min, Max]],
+ [4.5 [1, 8]],
+ [*value2*],
+ [],
+ [#h(12.0pt)a],
+ [3 (37.5%)],
+ [#h(12.0pt)b],
+ [3 (37.5%)],
+ [#h(12.0pt)c],
+ [2 (25%)],
+ [*group1*],
+ [],
+ [#h(12.0pt)a],
+ [4 (50%)],
+ [#h(12.0pt)b],
+ [4 (50%)],
+ [*group3*],
+ [],
+ [#h(12.0pt)c],
+ [4 (50%)],
+ [#h(12.0pt)d],
+ [4 (50%)],
+ [*group2*],
+ [],
+ [#h(12.0pt)e],
+ [4 (50%)],
+ [#h(12.0pt)f],
+ [4 (50%)],
+ table.hline(y: 17, stroke: 1pt),
+)
diff --git a/test/references/table_one/single_arg_with_groupby.docx.txt b/test/references/table_one/single_arg_with_groupby.docx.txt
new file mode 100644
index 0000000..31a435f
--- /dev/null
+++ b/test/references/table_one/single_arg_with_groupby.docx.txt
@@ -0,0 +1,1498 @@
+############################## [Content_Types].xml ##############################
+
+
+
+
+
+
+
+
+
+############################## _rels/.rels ##############################
+
+
+
+
+############################## word/_rels/document.xml.rels ##############################
+
+
+
+
+############################## word/styles.xml ##############################
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+############################## word/document.xml ##############################
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ e
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+ (
+
+
+
+ 50
+
+
+
+ %)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/references/table_one/single_arg_with_groupby.latex.txt b/test/references/table_one/single_arg_with_groupby.latex.txt
new file mode 100644
index 0000000..6da72d6
--- /dev/null
+++ b/test/references/table_one/single_arg_with_groupby.latex.txt
@@ -0,0 +1,33 @@
+\documentclass{article}
+\usepackage{threeparttable}
+\usepackage{multirow}
+\usepackage{booktabs}
+\begin{document}
+\begin{table}[!ht]
+\setlength\tabcolsep{0pt}
+\centering
+\begin{threeparttable}
+\begin{tabular}{@{\extracolsep{2ex}}*{4}{lccc}}
+\toprule
+ & & \multicolumn{2}{c}{\textbf{group1}} \\
+\cmidrule{3-4}
+ & \textbf{Total} & a & b \\
+\midrule
+\textbf{value1} & & & \\
+\hspace{12.0pt}Mean (SD) & 4.5 (2.45) & 2.5 (1.29) & 6.5 (1.29) \\
+\hspace{12.0pt}Median [Min, Max] & 4.5 [1, 8] & 2.5 [1, 4] & 6.5 [5, 8] \\
+\textbf{value2} & & & \\
+\hspace{12.0pt}a & 3 (37.5\%) & 2 (50\%) & 1 (25\%) \\
+\hspace{12.0pt}b & 3 (37.5\%) & 1 (25\%) & 2 (50\%) \\
+\hspace{12.0pt}c & 2 (25\%) & 1 (25\%) & 1 (25\%) \\
+\textbf{group3} & & & \\
+\hspace{12.0pt}c & 4 (50\%) & 2 (50\%) & 2 (50\%) \\
+\hspace{12.0pt}d & 4 (50\%) & 2 (50\%) & 2 (50\%) \\
+\textbf{group2} & & & \\
+\hspace{12.0pt}e & 4 (50\%) & 2 (50\%) & 2 (50\%) \\
+\hspace{12.0pt}f & 4 (50\%) & 2 (50\%) & 2 (50\%) \\
+\bottomrule
+\end{tabular}
+\end{threeparttable}
+\end{table}
+\end{document}
\ No newline at end of file
diff --git a/test/references/table_one/single_arg_with_groupby.txt b/test/references/table_one/single_arg_with_groupby.txt
new file mode 100644
index 0000000..e360a84
--- /dev/null
+++ b/test/references/table_one/single_arg_with_groupby.txt
@@ -0,0 +1,122 @@
+
+
+ |
+
+ |
+ |
+ group1 |
+
+
+ |
+ Total |
+ a |
+ b |
+
+ |
+ value1 |
+ |
+ |
+ |
+
+
+ Mean (SD) |
+ 4.5 (2.45) |
+ 2.5 (1.29) |
+ 6.5 (1.29) |
+
+
+ Median [Min, Max] |
+ 4.5 [1, 8] |
+ 2.5 [1, 4] |
+ 6.5 [5, 8] |
+
+
+ value2 |
+ |
+ |
+ |
+
+
+ a |
+ 3 (37.5%) |
+ 2 (50%) |
+ 1 (25%) |
+
+
+ b |
+ 3 (37.5%) |
+ 1 (25%) |
+ 2 (50%) |
+
+
+ c |
+ 2 (25%) |
+ 1 (25%) |
+ 1 (25%) |
+
+
+ group3 |
+ |
+ |
+ |
+
+
+ c |
+ 4 (50%) |
+ 2 (50%) |
+ 2 (50%) |
+
+
+ d |
+ 4 (50%) |
+ 2 (50%) |
+ 2 (50%) |
+
+
+ group2 |
+ |
+ |
+ |
+
+
+ e |
+ 4 (50%) |
+ 2 (50%) |
+ 2 (50%) |
+
+
+ f |
+ 4 (50%) |
+ 2 (50%) |
+ 2 (50%) |
+
+ |
+
\ No newline at end of file
diff --git a/test/references/table_one/single_arg_with_groupby.typ.txt b/test/references/table_one/single_arg_with_groupby.typ.txt
new file mode 100644
index 0000000..6a1d6c9
--- /dev/null
+++ b/test/references/table_one/single_arg_with_groupby.typ.txt
@@ -0,0 +1,71 @@
+
+#table(
+ rows: 15,
+ columns: 4,
+ column-gutter: 0.25em,
+ align: (left, center, center, center),
+ stroke: none,
+ table.hline(y: 0, stroke: 1pt),
+ [],
+ [],
+ table.cell(colspan: 2)[*group1*],
+ table.hline(y: 1, start: 2, end: 4, stroke: 0.75pt),
+ [],
+ [*Total*],
+ [a],
+ [b],
+ table.hline(y: 2, stroke: 0.75pt),
+ [*value1*],
+ [],
+ [],
+ [],
+ [#h(12.0pt)Mean (SD)],
+ [4.5 (2.45)],
+ [2.5 (1.29)],
+ [6.5 (1.29)],
+ [#h(12.0pt)Median [Min, Max]],
+ [4.5 [1, 8]],
+ [2.5 [1, 4]],
+ [6.5 [5, 8]],
+ [*value2*],
+ [],
+ [],
+ [],
+ [#h(12.0pt)a],
+ [3 (37.5%)],
+ [2 (50%)],
+ [1 (25%)],
+ [#h(12.0pt)b],
+ [3 (37.5%)],
+ [1 (25%)],
+ [2 (50%)],
+ [#h(12.0pt)c],
+ [2 (25%)],
+ [1 (25%)],
+ [1 (25%)],
+ [*group3*],
+ [],
+ [],
+ [],
+ [#h(12.0pt)c],
+ [4 (50%)],
+ [2 (50%)],
+ [2 (50%)],
+ [#h(12.0pt)d],
+ [4 (50%)],
+ [2 (50%)],
+ [2 (50%)],
+ [*group2*],
+ [],
+ [],
+ [],
+ [#h(12.0pt)e],
+ [4 (50%)],
+ [2 (50%)],
+ [2 (50%)],
+ [#h(12.0pt)f],
+ [4 (50%)],
+ [2 (50%)],
+ [2 (50%)],
+ table.hline(y: 15, stroke: 1pt),
+)
diff --git a/test/runtests.jl b/test/runtests.jl
index 52a7113..5771969 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -153,8 +153,6 @@ end
reftest(t, path) = @testset "$path" run_reftest(t, path, func)
@testset "table_one" begin
- @test_throws MethodError table_one(df)
-
t = table_one(df, [:value1])
reftest(t, "references/table_one/one_row")
@@ -235,6 +233,12 @@ end
)
t = table_one(data, [:value], groupby = [:group1, :group2], group_totals = :group2)
reftest(t, "references/table_one/missing_as_a_group_factor")
+
+ t = table_one(df)
+ reftest(t, "references/table_one/single_arg")
+
+ t = table_one(df, groupby = :group1)
+ reftest(t, "references/table_one/single_arg_with_groupby")
end