Skip to content

Commit 38dca86

Browse files
committed
Avoid repeated tibble subassignment
1 parent 8cb0b5e commit 38dca86

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

R/nest.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,14 @@ nest_parse_data <- function(pd_flat) {
359359

360360
nested <- left_join(internal, rhs, by = c("id" = "parent_"))
361361

362-
for (i in seq_along(nested$child)) {
363-
new <- combine_children(nested$child[[i]], nested$internal_child[[i]])
362+
children <- nested$child
363+
for (i in seq_along(children)) {
364+
new <- combine_children(children[[i]], nested$internal_child[[i]])
364365
# Work around is.null(new)
365-
nested$child[i] <- list(new)
366+
children[i] <- list(new)
366367
}
367-
nested <- nested[, setdiff(names(nested), "internal_child")]
368+
nested$child <- children
369+
nested$internal_child <- NULL
368370
nest_parse_data(nested)
369371
}
370372

0 commit comments

Comments
 (0)