Skip to content

Commit

Permalink
Merge pull request #47 from PumasAI/jk/fix-missing-as-group
Browse files Browse the repository at this point in the history
Fix `missing` as group in `table_one`
  • Loading branch information
jkrumbiegel authored Oct 24, 2024
2 parents a6d5cca + 6cc6d62 commit 4135532
Show file tree
Hide file tree
Showing 12 changed files with 2,238 additions and 988 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: julia-actions/setup-julia@a0a0978e28861c11a3490cee468f87d5b568851a # v2.5.0
with:
version: '1'
version: '1.10'
- uses: julia-actions/cache@824243901fb567ccb490b0d0e2483ccecde46834 # v2.0.5
- uses: quarto-dev/quarto-actions/setup@87b35bb88b36317fa36b5189e9553b4164a5c5a3 # v2.1.6
with:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- 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

- **Breaking** Footnotes are by default separated with linebreaks now. This can be changed by setting the new `Table` option `linebreak_footnotes = false` [#34](https://github.com/PumasAI/SummaryTables.jl/pull/34).
Expand Down
744 changes: 371 additions & 373 deletions README_files/figure-commonmark/cell-3-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
684 changes: 341 additions & 343 deletions README_files/figure-commonmark/cell-4-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
536 changes: 267 additions & 269 deletions README_files/figure-commonmark/cell-5-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function auto_round(number; target_digits::Int)
end

natural_lt(x::AbstractString, y::AbstractString) = NaturalSort.natural(x, y)
natural_lt(x, y) = x < y
natural_lt(x, y) = isless(x, y)

function validate_rowgaps(rowgaps, nrows)
nrows == 1 && !isempty(rowgaps) && error("No row gaps allowed for a table with one row.")
Expand Down
9 changes: 8 additions & 1 deletion src/table_one.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,14 @@ function table_one(
i_total_group = group_total_indices[ii]
i_parent_group = i_total_group - 1
next_key = length(df_analyses) == ikey ? nothing : keys(df_analyses)[ikey+1]
if next_key === nothing || key[i_parent_group] != next_key[i_parent_group] || ikey == length(df_analyses)

n_subgroups = count(keys(df_analyses)) do _key
Tuple(_key)[1:i_parent_group] === Tuple(key)[1:i_parent_group]
end
# if a group has only 1 subgroup, the total would be the same as that one so we skip it
n_subgroups == 1 && continue

if next_key === nothing || key[i_parent_group] !== next_key[i_parent_group] || ikey == length(df_analyses)
group_total_col = Cell[]

for i in 1:i_total_group
Expand Down
Loading

0 comments on commit 4135532

Please sign in to comment.