I have this matrix(head and tail is given below), and it has lat ,lon and variable for USA for a time period starts from January 1948 to December 2004:
# head of matrix
lon lat month value
1 -124.5 31.5 1980.1 NA
2 -123.5 31.5 1980.1 NA
3 -122.5 31.5 1980.1 NA
4 -121.5 31.5 1980.1 NA
5 -120.5 31.5 1980.1 NA
6 -119.5 31.5 1980.1 NA
# tail of matrix
lon lat month value
[129595,] -106.5 48.5 2004.12 0
[129596,] -105.5 48.5 2004.12 0
[129597,] -104.5 48.5 2004.12 71
[129598,] -103.5 48.5 2004.12 NA
[129599,] -102.5 48.5 2004.12 NA
[129600,] -101.5 48.5 2004.12 NA
I want to reshape it into this form which is for each month of the year for example this is for January 1980:
lon....> 31.5 32.5 33.5 .... 48.5
lat -101.5 value11 value12 value13
. -102.5 ....
. -103.5
. .
\/ . value ii
Is there any way I can do that?