[R] Aggregate time series from daily to monthly by date and site
Zilefac Elvis
zilefacelvis at yahoo.com
Sat Apr 5 06:02:03 CEST 2014
Hi,
I have daily data arranged by date and site. Keeping the number of columns as there are, I will like to aggregate (FUN=mean) from daily to monthly the following data (only part is shown here) which starts in 1971 and ends in 1980.
Year Month Day Site Sim001 Sim002 Sim003 Sim004
1 1971 1 1 GGG1 8.58 -12.67 4.45 -1.31
2 1971 1 1 GGG2 11.82 -9.94 -3.37 4.94
3 1971 1 1 GGG3 7.72 -11.94 -1.17 4.70
4 1971 1 1 GGG4 8.93 -10.81 4.66 2.88
5 1971 1 1 GGG5 9.82 -6.78 -4.19 -0.01
6 1971 1 1 GGG6 13.93 -3.39 -3.84 1.83
7 1971 1 1 GGG7 10.94 -7.58 1.74 -7.51
8 1971 1 1 GGG8 5.07 -16.09 1.26 1.12
9 1971 1 1 GGG9 11.13 -9.96 -7.06 5.25
10 1971 1 1 GG10 7.66 -8.68 -2.65 5.25
11 1971 1 1 GG11 1.06 6.14 -4.88 3.78
12 1971 1 1 GG12 14.93 -12.43 -4.06 4.94
13 1971 1 1 GG13 7.56 -10.81 -2.32 2.32
14 1971 1 1 GG14 6.18 -7.58 -1.64 9.83
15 1971 1 1 GG15 10.96 -0.62 0.56 -1.59
16 1971 1 1 GG16 4.94 1.52 0.31 6.45
17 1971 1 1 GG17 0.79 0.83 -0.35 4.26
18 1971 1 1 GG18 4.91 -3.29 -5.69 3.10
19 1971 1 1 GG19 0.68 -0.50 3.35 5.50
20 1971 1 1 GG20 4.50 1.14 4.84 6.94
21 1971 1 1 GG21 3.13 3.35 3.62 2.76
22 1971 1 1 GG22 2.91 1.10 0.77 5.10
23 1971 1 1 GG23 -2.27 -5.25 -3.05 1.95
24 1971 1 1 GG24 8.18 2.00 -0.42 15.13
25 1971 1 1 GG25 3.87 -4.09 -2.55 -9.18
26 1971 1 1 GG26 5.10 2.28 1.34 2.88
27 1971 1 1 GG27 7.23 2.46 2.89 4.28
28 1971 1 1 GG28 8.55 5.64 3.09 -5.01
29 1971 1 1 GG29 1.39 4.64 9.79 -0.27
30 1971 1 1 GG30 6.85 -12.11 4.98 1.91
31 1971 1 1 GG31 4.25 -2.21 9.59 -1.46
32 1971 1 1 GG32 -0.24 -16.54 4.99 -0.60
33 1971 1 1 GG33 9.86 -7.38 11.77 -8.99
34 1971 1 1 GG34 9.92 -16.33 13.07 -8.79
35 1971 1 1 GG35 5.11 -7.63 0.41 -3.09
36 1971 1 1 GG36 6.14 -11.61 10.38 -7.09
37 1971 1 1 GG37 8.14 -12.78 11.01 -5.20
38 1971 1 1 GG38 7.52 -12.86 3.43 -7.55
39 1971 1 1 GG39 4.19 -9.99 6.08 -4.04
40 1971 1 1 GG40 1.02 4.84 0.55 -3.80
41 1971 1 1 GG41 -2.43 -13.75 6.49 -10.66
42 1971 1 1 GG42 6.85 -12.33 2.85 -6.34
43 1971 1 1 GG43 4.94 -13.43 11.17 -3.62
44 1971 1 1 GG44 8.11 -21.13 11.32 -8.49
45 1971 1 1 GG45 7.34 -12.63 -0.89 -2.29
46 1971 1 1 GG46 10.56 -3.16 -0.48 0.38
47 1971 1 1 GG47 -6.52 1.61 10.80 5.25
48 1971 1 1 GG48 2.66 -2.36 1.86 8.60
49 1971 1 1 GG49 -4.89 5.54 6.63 5.83
50 1971 1 1 GG50 0.11 3.59 5.14 8.94
51 1971 1 1 GG51 3.90 1.23 4.13 9.86
52 1971 1 1 GG52 3.87 -0.25 8.72 4.62
53 1971 1 1 GG53 2.55 -1.49 15.01 4.33
54 1971 1 1 GG54 -0.20 -1.65 4.78 10.15
55 1971 1 1 GG55 5.09 0.90 5.56 7.87
56 1971 1 1 GG56 -2.40 -2.29 5.69 9.07
57 1971 1 1 GG57 1.32 -2.35 10.39 0.04
58 1971 1 1 GG58 3.49 -2.01 8.99 2.85
59 1971 1 1 GG59 4.93 -2.07 6.95 6.00
60 1971 1 1 GG60 -9.58 1.37 10.59 4.54
61 1971 1 1 GG61 9.08 -0.64 3.92 13.50
62 1971 1 1 GG62 2.85 4.75 3.40 12.39
63 1971 1 1 GG63 7.71 3.02 3.95 11.79
64 1971 1 1 GG64 4.50 5.44 0.87 6.29
65 1971 1 1 GG65 0.99 3.76 2.28 15.45
66 1971 1 1 GG66 8.72 5.16 1.11 15.82
67 1971 1 1 GG67 12.45 2.54 4.36 19.79
68 1971 1 1 GG68 8.83 4.11 6.21 13.12
69 1971 1 1 GG69 8.94 5.03 1.73 6.50
70 1971 1 1 GG70 5.05 -1.12 2.50 -4.63
71 1971 1 1 GG71 9.82 4.53 4.19 1.79
72 1971 1 1 GG72 11.72 -0.15 1.85 -0.80
73 1971 1 1 GG73 1.21 -4.98 8.65 1.29
74 1971 1 1 GG74 7.92 0.85 6.24 8.88
75 1971 1 1 GG75 3.45 -3.04 7.82 1.28
76 1971 1 1 GG76 1.34 -0.06 7.43 6.55
77 1971 1 1 GG77 8.25 -3.01 5.19 5.78
78 1971 1 1 GG78 2.92 -1.10 -1.71 5.46
79 1971 1 1 GG79 2.10 4.02 -3.16 2.83
80 1971 1 1 GG80 -3.19 1.77 -2.66 8.00
81 1971 1 1 GG81 4.75 -3.36 -7.00 6.25
82 1971 1 1 GG82 -0.30 1.56 -2.08 4.94
83 1971 1 1 GG83 1.69 -1.63 0.36 5.01
84 1971 1 1 GG84 3.31 1.12 8.61 5.32
85 1971 1 1 GG85 5.18 -2.39 3.22 2.95
86 1971 1 1 GG86 2.43 -2.05 7.99 7.46
87 1971 1 1 GG87 3.02 4.51 -1.19 5.71
88 1971 1 1 GG88 -5.31 1.52 11.38 -3.51
89 1971 1 1 GG89 -6.70 -0.61 10.20 3.51
90 1971 1 1 GG90 -5.90 2.54 8.87 9.46
91 1971 1 1 GG91 -4.73 2.88 7.23 8.55
92 1971 1 1 GG92 -8.13 6.79 8.07 6.71
93 1971 1 1 GG93 -7.67 5.50 2.77 7.36
94 1971 1 1 GG94 3.73 -2.36 9.61 10.96
95 1971 1 1 GG95 -2.40 4.18 -1.10 3.47
96 1971 1 1 GG96 1.46 -0.13 -2.05 -1.99
97 1971 1 1 GG97 -4.71 5.68 6.39 5.75
98 1971 1 1 GG98 0.33 1.82 6.60 1.56
99 1971 1 1 GG99 -3.11 3.21 -2.89 -4.38
100 1971 1 1 G100 2.45 0.21 -6.41 0.67
Thanks for your useful solution.
Atem.
More information about the R-help
mailing list