Category Statistics
In the built-in data set painters, the painters are classified according to the schools they belong. Each school can be characterized by its various statistics, such as mean composition, drawing, coloring and expression scores.
Suppose we would like to know which school has the highest mean composition score. We would have to first find out the mean composition score of each school. The following shows how to find the mean composition score of an arbitrarily chosen school.
Problem
Find out the mean composition score of school C in the data set painters.
Solution
The solution consists of a few steps:
- Create a logical index vector for school C.
- Find the child data set of painters for school C. For explanation, please consult the tutorial of Data Frame Row Slice.
- Find the mean composition score of school C.
Answer
The mean composition score of school C is 13.167.
Alternative Solution
Instead of computing the mean composition score manually for each school, use the tapply function to compute them all at once.
A B C D E F G H
10.400 12.167 13.167 9.100 13.571 7.250 13.857 14.000
Exercise
- Find programmatically the school with the highest composition scores.
- Find the percentage of painters whose color score is equal to or above 14.