Skip to content

Commit f249098

Browse files
authored
Merge pull request #85 from stemangiola/fix-unnest-with-new-purrr
replace imap, which is behaving inconsistently
2 parents 2af6a82 + 3ba62b6 commit f249098

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

R/tidyr_methods.R

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,32 @@ unnest_summarized_experiment <- function(data, cols, ...,
119119
}
120120

121121
# Do my trick to unnest
122-
data <- data |>
123-
mutate(!!cols := imap(
124-
!!cols, ~ .x %>%
125-
bind_cols_internal(
126-
# Attach back the columns used for nesting
127-
.data_ %>%
128-
select(-!!cols,
129-
-suppressWarnings(one_of(s_(my_se)$name,
130-
f_(my_se)$name))) %>%
131-
slice(rep(.y, ncol(.x) * nrow(.x))),
122+
data =
123+
data |>
124+
125+
# I have to use this because imap behave strangely
126+
rowid_to_column(var = "i___") |>
127+
mutate(!!cols := map2(
128+
!!cols, i___, ~ .x %>%
129+
bind_cols_internal(
130+
131+
# Attach back the columns used for nesting
132+
.data_ %>%
133+
select(-!!cols, - any_of(c(s_(my_se)$name, f_(my_se)$name))) %>%
134+
slice(rep(as.integer(.y), ncol(.x) * nrow(.x))),
132135

133-
# Column sample-wise or feature-wise
134-
column_belonging=source_column[
135-
.data_ %>%
136-
select(-!!cols,
137-
-suppressWarnings(one_of(s_(my_se)$name,
138-
f_(my_se)$name))) %>%
139-
colnames()
140-
]
141-
)
142-
))
136+
# Column sample-wise or feature-wise
137+
column_belonging =
138+
source_column[
139+
.data_ %>%
140+
select(-!!cols, - any_of(c(s_(my_se)$name, f_(my_se)$name))) %>%
141+
colnames()
142+
]
143+
)
144+
)) |>
145+
146+
# I have to use this because imap behave strangely
147+
select(-i___)
143148

144149
# Understand if split was done feature
145150
if(identical(

man/bind_rows.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)