From 1b8ee3816f56beba1a3bf9c406f80b14ff6c02b5 Mon Sep 17 00:00:00 2001 From: Yunuuuu Date: Mon, 6 Jan 2025 01:49:27 +0800 Subject: [PATCH] use combn directly to apply function --- R/fortify-upset.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/R/fortify-upset.R b/R/fortify-upset.R index 048bc2e5..c367c3d6 100644 --- a/R/fortify-upset.R +++ b/R/fortify-upset.R @@ -84,15 +84,14 @@ fortify_upset.list <- function(data, mode = "distinct", ...) { seq_len(vec_size(intersection)), function(n) { # generate all possible intersections - index <- utils::combn(vec_size(intersection), n) - lapply(seq_len(ncol(index)), function(i) { - intersection[index[, i, drop = TRUE]] <- TRUE + utils::combn(vec_size(intersection), n, function(index) { + intersection[index] <- TRUE list( intersection = intersection, # for each intersection, we define the size size = vec_size(action(data, intersection)) ) - }) + }, simplify = FALSE) } )