Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prune lbt07 to always keep "Any" row #823

Open
BFalquet opened this issue Feb 27, 2025 · 0 comments · May be fixed by #825
Open

Prune lbt07 to always keep "Any" row #823

BFalquet opened this issue Feb 27, 2025 · 0 comments · May be fixed by #825

Comments

@BFalquet
Copy link
Contributor

Use something like that in postprocessing:

prune_empty_level_but_any <- function (tt) {
  # If the output of this function is TRUE the row or split will be pruned
  if (is(tt, "TableRow")) { # label and data rows
    # browser() to check when to avoid doing this
    if (obj_name(tt) == "Any") {
      return(FALSE)
    } else {
      return(all_zero_or_na(tt))
    }
  }
  if (content_all_zeros_nas(tt)) { # content rows
    return(TRUE)
  }
  kids <- tree_children(tt)
  length(kids) == 0 # entire splits with no children remaining are pruned
}
result %>% prune_table(prune_func = prune_empty_level_but_any)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant