[R] monthly median in a daily dataset

HUXTERE emilyhuxter at gmail.com
Sun Dec 19 23:31:33 CET 2010


Hello,

I have a multi-year dataset (see below) with date, a data value and a flag
for the data value. I want to find the monthly median for each month in this
dataset and then plot it. If anyone has suggestions they would be greatly
apperciated. It should be noted that there are some dates with no values and
they should be removed.

Thanks
Emily

> print ( str(data$flow$daily) )
'data.frame':   16071 obs. of  3 variables:
 $ date :Class 'Date'  num [1:16071] -1826 -1825 -1824 -1823 -1822 ...
 $ value: num  NA NA NA NA NA NA NA NA NA NA ...
 $ flag : chr  "" "" "" "" ...
NULL

520    2008-11-01 0.034     
1041   2008-11-02 0.034     
1562   2008-11-03 0.034     
2083   2008-11-04 0.038     
2604   2008-11-05 0.036     
3125   2008-11-06 0.035     
3646   2008-11-07 0.036     
4167   2008-11-08 0.039     
4688   2008-11-09 0.039     
5209   2008-11-10 0.039     
5730   2008-11-11 0.038     
6251   2008-11-12 0.039     
6772   2008-11-13 0.039     
7293   2008-11-14 0.038     
7814   2008-11-15 0.037     
8335   2008-11-16 0.037     
8855   2008-11-17 0.037     
9375   2008-11-18 0.037     
9895   2008-11-19 0.034    B
10415  2008-11-20 0.034    B
10935  2008-11-21 0.033    B
11455  2008-11-22 0.034    B
11975  2008-11-23 0.034    B
12495  2008-11-24 0.034    B
13016  2008-11-25 0.034    B
13537  2008-11-26 0.033    B
14058  2008-11-27 0.033    B
14579  2008-11-28 0.033    B
15068  2008-11-29 0.034    B
15546  2008-11-30 0.035    B
521    2008-12-01 0.035    B
1042   2008-12-02 0.034    B
1563   2008-12-03 0.033    B
2084   2008-12-04 0.031    B
2605   2008-12-05 0.031    B
3126   2008-12-06 0.031    B
3647   2008-12-07 0.032    B
4168   2008-12-08 0.032    B
4689   2008-12-09 0.032    B
5210   2008-12-10 0.033    B
5731   2008-12-11 0.033    B
6252   2008-12-12 0.032    B
6773   2008-12-13 0.031    B
7294   2008-12-14 0.030    B
7815   2008-12-15 0.030    B
8336   2008-12-16 0.029    B
8856   2008-12-17 0.028    B
9376   2008-12-18 0.028    B
9896   2008-12-19 0.028    B
10416  2008-12-20 0.027    B
10936  2008-12-21 0.027    B
11456  2008-12-22 0.028    B
11976  2008-12-23 0.028    B
12496  2008-12-24 0.029    B
13017  2008-12-25 0.029    B
13538  2008-12-26 0.029    B
14059  2008-12-27 0.030    B
14580  2008-12-28 0.030    B
15069  2008-12-29 0.030    B
15547  2008-12-30 0.031    B
15851  2008-12-31 0.031    B
-- 
View this message in context: http://r.789695.n4.nabble.com/monthly-median-in-a-daily-dataset-tp3094917p3094917.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list