I have a data set that looks like below. In real data set, there are 8619 rows.
Athlete      Competing Country  Year    Total Medals
Michael Phelps    United States 2012    6
Alicia Coutts     Australia     2012    5
Missy Franklin    United States 2012    5
Brian Leetch      United States 2002    1
Mario Lemieux     Canada        2002    1
Ylva Lindberg     Sweden        2002    1
Eric Lindros      Canada        2002    1
Ulrica Lindström  Sweden        2002    1
Shelley Looney    United States 2002    1
and I want to rearrange this data by country, year and the sum of the medals.
I want result like
Country        Year  SumOfMedals
United States  2012  11
United States  2002   2
...
by(newmd$Total.Medals, newmd$Year, FUN=sum)
by(md$Total.Medals, md$Competing.Country, FUN=sum)
I tired to use by argument, but still stuck. Can any of you help me out?
 
     
    