Skip to content

Commit acd69f1

Browse files
committed
replace imap, which is behaving inconsistently
1 parent 638183d commit acd69f1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

R/tidyr_methods.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,17 @@ unnest_summarized_experiment <- function(data, cols, ..., keep_empty=FALSE, pt
188188
# Do my trick to unnest
189189
data =
190190
data |>
191-
mutate(!!cols := imap(
192-
!!cols, ~ .x %>%
191+
192+
# I have to use this because imap behave strangely
193+
rowid_to_column(var = "i___") |>
194+
mutate(!!cols := map2(
195+
!!cols, i___, ~ .x %>%
193196
bind_cols_internal(
194197

195198
# Attach back the columns used for nesting
196199
.data_ %>%
197200
select(-!!cols, -suppressWarnings( one_of(s_(my_se)$name, f_(my_se)$name))) %>%
198-
slice(rep(.y, ncol(.x) * nrow(.x))),
201+
slice(rep(as.integer(.y), ncol(.x) * nrow(.x))),
199202

200203
# Column sample-wise or feature-wise
201204
column_belonging =
@@ -205,7 +208,10 @@ unnest_summarized_experiment <- function(data, cols, ..., keep_empty=FALSE, pt
205208
colnames()
206209
]
207210
)
208-
))
211+
)) |>
212+
213+
# I have to use this because imap behave strangely
214+
select(-i___)
209215

210216
# Understand if split was done feature
211217
if(identical(

0 commit comments

Comments
 (0)