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

[Bug]: When using split_cols_by_multivar in layout, make_ard=T doesn't work #970

Closed
vchang-cims opened this issue Dec 12, 2024 · 1 comment · Fixed by #986
Closed

[Bug]: When using split_cols_by_multivar in layout, make_ard=T doesn't work #970

vchang-cims opened this issue Dec 12, 2024 · 1 comment · Fixed by #986
Assignees

Comments

@vchang-cims
Copy link

When building a table with split_cols_by_multivar in the layout, and then passing the table into as_result_df(make_ard = TRUE), the following error occurs:

'Error in data.frame(flattened_cols_names) : 
  row names contain missing values'

Here is a reproducible example:

n <- 400

df <- tibble(
  arm = factor(sample(c("Arm A", "Arm B"), n, replace = TRUE), levels = c("Arm A", "Arm B")),
  country = factor(sample(c("CAN", "USA"), n, replace = TRUE, prob = c(.55, .45)), levels = c("CAN", "USA")),
  gender = factor(sample(c("Female", "Male"), n, replace = TRUE), levels = c("Female", "Male")),
  handed = factor(sample(c("Left", "Right"), n, prob = c(.6, .4), replace = TRUE), levels = c("Left", "Right")),
  age = rchisq(n, 30) + 10
) %>% mutate(
  weight = 35 * rnorm(n, sd = .5) + ifelse(gender == "Female", 140, 180)
)

colfuns <- list(
  function(x) in_rows(mean = mean(x), .formats = "xx.x"),
  function(x) in_rows("# x > 5" = sum(x > .5), .formats = "xx")
)


lyt <- basic_table() %>%
  split_cols_by("arm") %>%
  split_cols_by_multivar(c("age", "weight")) %>%
  split_rows_by("country"
  ) %>%
  summarize_row_groups() %>%
  analyze_colvars(afun = colfuns)


tbl <- build_table(lyt, df)
tbl
as_result_df(tbl,make_ard = T)

Thank you!

@shajoezhu
Copy link
Collaborator

hi @vchang-cims , thanks a lot for raising this. we are actively working on this. thanks for bring this to our attention

@Melkiades Melkiades self-assigned this Dec 13, 2024
@Melkiades Melkiades removed their assignment Dec 27, 2024
@Melkiades Melkiades added the ARD label Jan 27, 2025
@Melkiades Melkiades self-assigned this Jan 27, 2025
@Melkiades Melkiades linked a pull request Jan 27, 2025 that will close this issue
Melkiades added a commit that referenced this issue Jan 27, 2025
Fix #977 #976 #970

---------

Signed-off-by: Davide Garolini <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Emily de la Rua <[email protected]>
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.

3 participants