i am new to R and a bit overwhelmed by an assignment. i am asked to create a new dataframe out of an existing one ( the diamonds data that come preinstalled with ggplot2). The dataframe should look as follows:
mean_price median_price min_price max_price n
All sorted by clarity where n is the number of entries in that clarity category.
I know i can access the clarity with
diamonds$clarityand i know i can get mean, median etc... with
mean(diamonds$price)etc..
But how do i sort it according to clarity and put it into a new dataframe ?