map関数についてはTokyoRの@kilometerさんの記事がよくわかる。https://qiita.com/kilometer/items/7184904765fbf0f33f04
ここではハマった内容を残しておく。
iris |> group_by(Species) |> nest() |> mutate(result = map(.x = data, .f=~shapiro.test(Sepal.Length))) Error in `mutate()`: ℹ In argument: `result = map(.x = data, .f = ~shapiro.test(Sepal.Length))`. ℹ In group 1: `Species = setosa`. Caused by error in `map()`: ℹ In index: 1. Caused by error in `stopifnot()`: ! オブジェクト 'Sepal.Length' がありません
iris |> group_by(Species) |> nest() |> mutate(result = map(.x = data, .f=~shapiro.test(.x$Sepal.Length)))
iris |> summarize(result = list(shapiro.test(Sepal.Length)), .by = Species) |> unpack(result)
iris |> summarize(result = broom::tidy(shapiro.test(Sepal.Length)), .by = Species) |> unpack(result)
iris |> summarize(result = list(shapiro.test(Sepal.Length)), .by = Species) |> deframe()