If I have a dataframe x.df as follows:
> x.df <- data.frame(Year = c(2000, 2000, 2000, 2000, 2000, 2001, 2001,
2001, 2001, 2002), Group = c(1, 1, 1, 2, 2, 1, 2, 2, 3, 1), Eye_Color =
c("blue", "blue", "brown", "green", "green", "blue", "brown", "blue",
"blue", "blue"))

> x.df
   Year Group Eye_Color
1  2000     1      blue
2  2000     1      blue
3  2000     1     brown
4  2000     2     green
5  2000     2     green
6  2001     1      blue
7  2001     2     brown
8  2001     2      blue
9  2001     3      blue
10 2002     1      blue

how can I turn it into a new dataframe that would take the data from
multiple rows of Year/Group combinations and output the data into one row
for each combination, like this:
> x_new.df
  Year Group No_blue No_brown No_green
1 2000     1       2        1        0
2 2000     2       0        0        2
3 2001     1       1        0        0
4 2001     2       1        1        0
5 2001     3       1        0        0
6 2002     1       1        0        0

I've been trying to use for loops, but I'm wondering if anyone has a better
or more simple suggestion.

	[[alternative HTML version deleted]]

