[R] Average for Huge file

rafitoariaz rafitoariaz at hotmail.com
Wed Apr 25 19:49:07 CEST 2012


Hi. I would use the function aggregate, but first you will have to tag each
row with a special code so R can recognize the group of data and apply the
function you desire. For example, with your data I would do this:

Date                                         Pm      FF         LL          
KK    HH     NN        Ww        DD      code
 01/01/2012 00:00:00          349     120       10             8     1178  
1292    2005      762     01_01_2012_1
 01/01/01/2012 00:00:05     356     119       12            7     1167  
1289     1992    778     01_01_2012_1
 01/01/2012 00:00:10           360     115       15           8      189     
1302     2010   770      01_01_2012_1
 01/01/2012 00:00:15          349     120       10             8     1178  
1292    2005      762     01_01_2012_1
 01/01/01/2012 00:00:20     356     119       12            7     1167  
1289     1992    778     01_01_2012_2
 01/01/2012 00:00:25           360     115       15           8      189     
1302     2010   770      01_01_2012_2
 01/01/2012 00:00:30           360     115       15           8      189     
1302     2010   770      01_01_2012_2

##Then apply the function aggregate
aggregate(name  of the variable you want to obtain the mean,
by=list(variable used for grouping),FUN=mean)
For example, if you want to aggregate Pm by groups of 15 min, you write it
like this
aggregate(Pm,by=list(code),FUN=sum)
and you'll obtain the mean of the rows that have the same code . In this
example, you'll obtain the mean of  two groups: the Pm measurments wich
their labels are 01_01_2012_1 and 01_01_2012_2.
Hope it works

M.C. Luis Antonio Arias Medellín
National Institute of Public Health
Cuernavaca, Morelos, Mexico

--
View this message in context: http://r.789695.n4.nabble.com/Average-for-Huge-file-tp4586926p4587482.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list