I'd like to be able to average the values across Small.area for every given Big.area. I then want to plot a line graph with year on the X and the mean of values for small.area on the Y colored by the big.area - i.e. a line for every value of the averaged small.area colored by Big.area
| Year | Big.area | Small.area | Value |
|---|---|---|---|
| 2011 | A | a | 10 |
| 2011 | A | b | 24 |
| 2011 | B | c | 32 |
| 2011 | B | d | 22 |
| 2012 | A | a | 20 |
| 2012 | A | b | 30 |
| 2012 | B | c | 40 |
| 2012 | B | d | 10 |
| 2013 | A | a | 15 |
| 2013 | A | b | 34 |
| 2013 | B | c | 10 |
| 2013 | B | d | 30 |
| 2014 | A | a | 15 |
| 2014 | A | b | 35 |
| 2014 | B | c | 25 |
| 2014 | B | d | 35 |
so I'd end up with a table like
| Year | Big.area | mean.small.areas |
|---|---|---|
| 2011 | A | 17 |
| 2011 | B | 27 |
| 2012 | A | 25 |
| 2012 | B | 25 |
| 2013 | A | 24.5 |
| 2013 | B | 20 |
| 2014 | A | 25 |
| 2014 | B | 30 |
which I can then plot using
ggplot(df, aes(x= Year, y =mean.small.area, color = Big.area))+geom_line()
Any ideas? Thanks for any suggestions

with(df1, mean(Value[Big.area == "A" & Year == 2011])) [1] 17- akrun