Skip to content

Issue with VARN sorting #202

Description

@Fmenius

A trainee discovered when creating a demographic table that the set_order_count_method("byvarn") seems to mess up when combined with a total row.

Context in our training we show solving this by creating an AGEGR1 factor, but this user saw that AGEGR1N is available in ADSL and wanted to change the default sort to us the VARN.

Our original code solution from our training (with AGEGR1 as factor):

add_layer(
group_count(AGEGR1, by = "Age Categories n (%)") %>%
add_total_row(fmt=f_str("xx",n), count_missings=FALSE, sort_value=-Inf) %>%
set_total_row_label("n") %>%
set_missing_count(f_str("xx", n), denom_ignore=TRUE, "Missing" = NA)
) %>%

Users code by VARN:

l_agec <- group_count(t, AGEGR1, by = "Age Categories n (%)") %>%
set_order_count_method("byvarn") %>%
add_total_row(fmt = f_str("xx",n), count_missings = FALSE, sort_value=-Inf) %>%
set_total_row_label("n") %>%
set_missing_count(fmt = f_str("xx", n), denom_ignore = TRUE, "Missing" = NA)

user's result - see ORD LAYER 2 - see example 1

Image

user's result if total row is not included - see example 2

Image

Mike Stackhouse thinks this is a bug: "This looks like a bug. I’ve been doing some updates so now is a good time to file it. Seems like the total row is accidentally setting the entire set of values to its sort value."

Full code for original solution to show context.

demog1_answer.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions