for example, if I had the following data set (see below), how would I split the data so that I could have the mean age for people with their own hair colour (like everyone who has red hair), by year? I have tried the split function, but it only allows me to make two-column subsets.

So my goal would be: the mean age of blonde people in 2016, mean age of brown haired people in 2016, etc. for every colour, for every year.

I am very new to R, so please answer in an easy to follow method (sorry lol).

```
Year    Age Hair Colour
2016    12  brown
2016    13  brown
2016    15  blonde
2016    18  blonde
2016    99  black
2016    1   black
2017    34  black
2017    28  green
2017    39  blonde
2017    58  red
2017    53  red
2017    5   brown
2017    65  blonde
2018    77  grey
2018    32  black
2018    22  brown
2018    33  brown
2018    44  brown
2018    63  brown
2018    63  green
2018    29  purple
2018    96  red
2018    15  brown

```