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

Refactoring of analyze_vars with specifics for .stat_names #1361

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Melkiades
Copy link
Contributor

Pull Request

Fixes #1352

@Melkiades Melkiades marked this pull request as draft December 11, 2024 14:14
all obs
—————————————————————
n 4
Mean (SD) 2.5 (1.3)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be NAs

n 5
a 2 (40%)
b 1 (20%)
NA 2 (40%)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lost NA

8 mean_ci (4.57, 5.69) 0 Mean 95% CI
9 mean_sei (4.89, 5.38) 0 Mean -/+ 1xSE
10 mean_sdi (4.35, 5.91) 0 Mean -/+ 1xSD
2 sum 48.7 0 Sum
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this calc changed?

.var,
...) {
checkmate::assert_flag(na.rm)
s_summary <- function(x, denom, control, ...) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still to test correctly: denom and control handling

R/analyze_variables.R Outdated Show resolved Hide resolved
@Melkiades Melkiades marked this pull request as ready for review December 16, 2024 16:00
out <- levels_per_stats
for (stat_i in seq_along(levels_per_stats)) {
common_stat_names <- intersect(names(levels_per_stats), names(labels_in))
nm_of_levs <- levels_per_stats[[stat_i]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to comment better

#'
#' @return A `list` with modified elements `x`, `.formats`, `.labels`, and `.indent_mods`.
#' @return A `list` with modified elements `stat_out`, `.formats`, `.labels`, `.levels`, and `.indent_mods`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fix: ungroup_stats should be removed in favor of get_*_from_stats

Comment on lines +296 to -303
empty_pval <- "pval" %in% names(stat_out) && length(stat_out[["pval"]]) == 0
empty_pval_counts <- "pval_counts" %in% names(stat_out) && length(stat_out[["pval_counts"]]) == 0
stat_out <- unlist(stat_out, recursive = FALSE)

# If p-value is empty it is removed by unlist and needs to be re-added
if (empty_pval) x[["pval"]] <- character()
if (empty_pval_counts) x[["pval_counts"]] <- character()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are if pval is NULL?

n 5
FALSE 1 (20%)
TRUE 2 (40%)
NA 2 (40%)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lost NA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

return stats in a named list
1 participant