Search code examples
rr-mosaic

Iris dataset mean() by species


I want to create some mean of sepal.length, but divided by species. Using mosaic package

mean(Sepal.Length~Species)

It didn't work


Solution

  • A base R solution

    aggregate(Sepal.Length ~ Species, data=iris, mean)
         Species Sepal.Length
    1     setosa        5.006
    2 versicolor        5.936
    3  virginica        6.588