diff --git a/R/mutate.R b/R/mutate.R index cda8943..bad8aad 100644 --- a/R/mutate.R +++ b/R/mutate.R @@ -161,8 +161,7 @@ mutate_df <- function(.data, ...) { cond_nms[i] <- names(conditions)[[i]] context$.data[[cond_nms[i]]] <- res } else { - if (is.null(res_nms)) names(res) <- names(conditions)[[i]] - context$.data[[names(res)]] <- res + context$.data[[names(conditions)[[i]]]] <- res } } list( diff --git a/inst/tinytest/test_mutate.R b/inst/tinytest/test_mutate.R index f61e68c..720119b 100644 --- a/inst/tinytest/test_mutate.R +++ b/inst/tinytest/test_mutate.R @@ -217,7 +217,7 @@ expect_equal( models <- mtcars %>% nest_by(cyl) %>% mutate(model = list(lm(mpg ~ wt, data = data))) expect_equal( lapply(models$model, class), - list(model = "lm", model = "lm", model = "lm"), + list("lm", "lm", "lm"), info = "List columns can be mutated: 3" )