-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
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!