Data:
i <- iris %>%
group_by(Species) %>%
distinct(Sepal.Length)
Expected output: each species should have a unique row, and the values of Sepal.Length should be comma-separated in a second column.
Probably this is what are after
iris %>%
summarise(Sepal.Length = toString(unique(Sepal.Length)), .by = Species)
or one of its base R equivalents
aggregate(Sepal.Length ~ Species, iris, (x) toString(unique(x)))
which gives
Species
1 setosa
2 versicolor
3 virginica
Sepal.Length
1 5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.4, 4.8, 4.3, 5.8, 5.7, 5.2, 5.5, 4.5, 5.3
2 7, 6.4, 6.9, 5.5, 6.5, 5.7, 6.3, 4.9, 6.6, 5.2, 5, 5.9, 6, 6.1, 5.6, 6.7, 5.8, 6.2, 6.8, 5.4, 5.1
3 6.3, 5.8, 7.1, 6.5, 7.6, 4.9, 7.3, 6.7, 7.2, 6.4, 6.8, 5.7, 7.7, 6, 6.9, 5.6, 6.2, 6.1, 7.4, 7.9, 5.9