I have an extensive block of code that I\'ve written using dplyr syntax in R. However, I am trying to put that code in a loop, so that I can ultimately create multiple output fi
As I mentioned in my comment, if you really need the results separated, it will probably be easier to just use group_by
and then split()
the results:
iris %>%
group_by(Species) %>%
summarise(mn = mean(Petal.Length)) %>%
split(.,.$Species)
$setosa
# A tibble: 1 × 2
Species mn
1 setosa 1.462
$versicolor
# A tibble: 1 × 2
Species mn
1 versicolor 4.26
$virginica
# A tibble: 1 × 2
Species mn
1 virginica 5.552