Guidelines : 1. File to be used for "df" is copied below:
A B C D Date Year
14.99 9.99 3.99 2.99 1/1/2002 2002
10.99 8.99 3.99 2.99 1/1/2006 2006
14.99 9.99 1/1/2006 2006
14.99 9.99 3.99 2.99 1/1/1998 1998
14.99 12.99 3.99 2.99 12/25/2012 2012
10.99 10.99 3.99 2.99 4/1/2014 2014
14.99 9.99 3.99 2.99 4/15/2011 2011
14.99 12.99 9/27/2013 2013
14.99 12.99 5/2/2014 2014
14.99 12.99 3.99 2.99 6/17/2014 2014
14.99 12.99 6/7/2013 2013
14.99 12.99 3.99 2.99 3/1/2013 2013
14.99 9.99 3.99 2.99 11/17/2007 2007
14.99 9.99 3.99 2.99 1/1/1987 1987
19.99 17.99 5.99 4.99 6/13/2014 2014
10.99 7.99 3.99 2.99 2/11/2014 2014
14.99 12.99 3.99 2.99 5/9/2014 2014
9.99 2.99 1/1/2003 2003
14.99 9.99 3.99 2.99 1/1/2003 2003
14.99 9.99 3.99 2.99 11/2/2012 2012
14.99 12.99 3.99 2.99 7/17/2013 2013
14.99 12.99 3.99 2.99 7/1/1980 1980
10.99 8.99 3.99 2.99 9/30/2011 2011
9.99 2.99 1/1/1996 1996
14.99 12.99 3/7/2014 2014
14.99 9.99 3.99 2.99 7/29/1966 1966
9.99 1/1/1966 1966
14.99 12.99 3.99 2.99 3/5/2013 2013
14.99 9.99 3.99 2.99 1/1/1998 1998
12.99 9.99 3.99 2.99 7/11/2007 2007
14.99 9.99 3.99 2.99 1/1/2004 2004
14.99 9.99 3.99 2.99 1/1/1992 1992
14.99 12.99 10/4/2013 2013
6.99 6.99 1/30/2015 2015
- Blank Values to be replaced by
NA
in data.frame "df". - Whenever more than 1 row is present for any year keep only 1 row for that year and update the value in columns "A", "B", "C", "D" with mean for any corresponding year ("NA" should not be counted for taking mean)
- Sort the data frame obtained in above step by year
I had used below command for aggregate and sort, but it didn't worked:
aggregate(x=df[,-c(5)], by=list(df$Year), FUN = Mean, na.rm=TRUE)