1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 18:01:50 +02:00

bind_rows

This commit is contained in:
2023-02-10 17:09:48 +01:00
parent 03294c7901
commit 2007c3eef3
15 changed files with 48 additions and 31 deletions

View File

@ -124,7 +124,7 @@ bug_drug_combinations <- function(x,
m <- as.matrix(table(x))
data.frame(S = m["S", ], I = m["I", ], R = m["R", ], stringsAsFactors = FALSE)
})
merged <- do.call(rbind, pivot)
merged <- do.call(bind_rows2, pivot)
out_group <- data.frame(
mo = rep(unique_mo[i], NROW(merged)),
ab = rownames(merged),
@ -144,14 +144,14 @@ bug_drug_combinations <- function(x,
}
out_group <- cbind(group_values, out_group)
}
out <- rbind(out, out_group, stringsAsFactors = FALSE)
out <- bind_rows2(out, out_group)
}
out
}
# based on pm_apply_grouped_function
apply_group <- function(.data, fn, groups, drop = FALSE, ...) {
grouped <- pm_split_into_groups(.data, groups, drop)
res <- do.call(rbind, unname(lapply(grouped, fn, ...)))
res <- do.call(bind_rows2, unname(lapply(grouped, fn, ...)))
if (any(groups %in% colnames(res))) {
class(res) <- c("grouped_data", class(res))
res <- pm_set_groups(res, groups[groups %in% colnames(res)])