year
1999 1999 1999 2003 2003 2005 2005 2005 2005 2007 2009 2009 2009
A1
15 7 24 6 65 5 89 56 21 15 19 7 23
Above table shows a data frame. I want to have a vector, lets say "median1" which has the median of those values in a1 corresponds to each year. And I know that with a for loop it is easy but I am trying to find a 'vectorized' based solution.