Suppose I have the following data frame formatted as such:
x y
2001 Apples
2001 Apples
2001 Apples
2001 Oranges
2001 Oranges
2002 Apples
2002 Apples
2002 Apples
2002 Apples
2002 Oranges
2002 Oranges
2002 Oranges
How could I combine this aggregate this data so the result would be like this:
x y Frequency
2001 Apples 3
2001 Oranges 2
2002 Oranges 3
2002 Apples 4
I know that tables are good for showing frequency, but I am not sure how to aggregate this data? I have tried doing something like aggregate(df1$x ~ df1$y, df1, FUN = sum)
, but that did not yield the expected results.