Hi all,

I know this is easy, but I really do not have any idea to solve it.

I have this kind of data set:

dat <- read.table(text="Day Year Jan Feb Mar Apr
  1  2012 0 2.5 0.5 2
  2  2012 0 6.5 0 29
  3  2012 0 9.5 0 0
  4  2012 0 0 8 0.5
  5  2012 0 5 0.5 110.5
  6  2012 0 4 3.5 22
  7  2012 11 0 12.5 3.5
  8  2012 0 5 8 36.5
  1  2013 0 2.5 0.5 2
  2  2013 0 6.5 0 29
  3  2013 0 9.5 0 0
  4  2013 0 0 8 0.5
  5  2013 0 5 0.5 110.5
  6  2013 0 4 3.5 22
  7  2013 11 0 12.5 3.5
  8  2013 0 5 8 36.5",sep="",header=TRUE)

and I want it to be in this form:

    Year       Day Month Amount  2012 1 1 0  2012 2 1 0  2012 3 1 0  2012 4
1 0  2012 5 1 0  2012 6 1 0  2012 7 1 11  2012 8 1 0  2012 1 2 2.5  2012 2 2
6.5  2012 3 2 9.5  2012 4 2 0  2012 5 2 5  2012 6 2 4  2012 7 2 0  2012 8 2
5  2012 1 3 0.5  2012 2 3 0  2012 3 3 0  2012 4 3 8  2012 5 3 0.5  2012 6 3
3.5  2012 7 3 12.5  2012 8 3 8  2012 1 4 2  2012 2 4 29  2012 3 4 0  2012 4
4 0.5  2012 5 4 110.5  2012 6 4 22  2012 7 4 3.5  2012 8 4 36.5     2013 1 1
0  2013 2 1 0  2013 3 1 0  2013 4 1 0  2013 5 1 0  2013 6 1 0  2013 7 1 11
2013 8 1 0  2013 1 2 2.5  2013 2 2 6.5  2013 3 2 9.5  2013 4 2 0  2013 5 2 5
2013 6 2 4  2013 7 2 0  2013 8 2 5  2013 1 3 0.5  2013 2 3 0  2013 3 3 0
2013 4 3 8  2013 5 3 0.5  2013 6 3 3.5  2013 7 3 12.5  2013 8 3 8  2012 1 4
2  2012 2 4 29  2012 3 4 0  2012 4 4 0.5  2012 5 4 110.5  2012 6 4 22  2012
7 4 3.5  2012 8 4 36.5  2013 1 4 2  2013 2 4 29  2013 3 4 0  2013 4 4 0.5
2013 5 4 110.5  2013 6 4 22  2013 7 4 3.5  2013 8 4 36.5
I want to rearrange the data according to the YEAR (year by year)

Thank you.

Regards,
Dila

	[[alternative HTML version deleted]]

