aggregate function

#1
Hi All,

I have the following data:

Year Day Month Time Ambient_Air_Temperature Wind_Speed Precipitation
1 2002 1 January 15 -7.980 2.668 146.90
2 2002 1 January 30 -8.090 2.541 146.90
3 2002 1 January 45 -8.130 2.420 146.90
4 2002 1 January 100 -8.150 2.415 146.90
5 2002 1 January 115 -8.110 2.486 146.90
6 2002 1 January 130 -8.160 2.175 146.90
7 2002 1 January 145 -8.050 1.973 146.90
8 2002 1 January 200 -7.780 1.844 146.90
9 2002 1 January 215 -7.550 2.148 146.90
10 2002 1 January 230 -7.670 1.619 146.90
11 2002 1 January 245 -7.710 2.197 146.90
12 2002 1 January 300 -7.790 1.828 146.90
13 2002 1 January 315 -7.760 2.387 146.90
14 2002 1 January 330 -7.780 1.975 146.90
15 2002 1 January 345 -7.630 2.551 146.90
16 2002 1 January 400 -7.550 2.113 146.90
17 2002 1 January 415 -7.500 1.300 146.90
18 2002 1 January 430 -7.360 1.442 146.90
19 2002 1 January 445 -7.240 1.344 146.90
20 2002 1 January 500 -7.200 0.861 146.90
21 2002 1 January 515 -7.200 0.563 146.90
22 2002 1 January 530 -7.130 0.881 146.90
23 2002 1 January 545 -7.240 1.222 146.90
24 2002 1 January 600 -7.230 1.202 146.90
25 2002 1 January 615 -7.270 0.851 146.90
26 2002 1 January 630 -7.490 0.533 146.90
27 2002 1 January 645 -8.270 0.311 146.90
28 2002 1 January 700 -8.810 0.032 146.90
29 2002 1 January 715 -9.170 0.000 146.90
30 2002 1 January 730 -8.400 0.135 146.90
31 2002 1 January 745 -8.270 0.067 146.90
32 2002 1 January 800 -8.510 0.000 146.90
33 2002 1 January 815 -8.950 0.000 147.00
34 2002 1 January 830 -9.390 0.000 146.90
35 2002 1 January 845 -9.280 0.000 146.90
36 2002 1 January 900 -9.060 0.088 146.90
37 2002 1 January 915 -8.470 0.066 146.90
38 2002 1 January 930 -7.910 0.587 146.90
39 2002 1 January 945 -7.400 0.220 146.90
40 2002 1 January 1000 -6.953 0.390 146.90
41 2002 1 January 1015 -6.753 0.585 146.90
42 2002 1 January 1030 -6.545 0.835 148.70
43 2002 1 January 1045 -6.304 0.792 183.30
44 2002 1 January 1100 -5.932 1.242 149.20
45 2002 1 January 1115 -5.888 1.641 147.20
46 2002 1 January 1130 -6.031 2.027 147.10
47 2002 1 January 1145 -6.084 2.100 147.10
48 2002 1 January 1200 -5.862 1.822 147.10
49 2002 1 January 1215 -5.697 1.565 147.10
50 2002 1 January 1230 -5.559 1.468 147.20
51 2002 1 January 1245 -5.236 1.390 147.20
52 2002 1 January 1300 -4.976 1.002 149.20
53 2002 1 January 1315 -4.903 1.474 154.80


and I want to get the average data per day " sum over the Time" so what I'm expecting is one value "average" for each variable in day 1
it should look as follows:

year day month Ambient_Air_Temperature Wind_Speed Precipitation
2002 1 January ?? ?? ??


Thank you,

Marwah
 
#2
I have tried the following but it only gives the average for January, and I have data from Jan. to Dec.

data2002=aggregate(data[,c("Ambient_Air_Temperature","Wind_Speed","Precipitation")], by=list(data$Day), "mean")
 
C

consuli1

Guest
#3
Code:
somemeansperday=aggregate(data[,c("Ambient_Air_Temperature","Wind_Speed","Precipitation")], by=list(data$Year, data$Month, data$Day ), "mean")
should calculate the mean temperature per day based on the given temperature data within each day.

Regards
Consuli