Skip to content
Prev 202049 / 398503 Next

column of dates into time series

On Nov 29, 2009, at 12:41 PM, David Winsemius wrote:

            
Actually those were not so odd. I was just interpreting them  
incorrectly. Those were the tables of counts (i.e. counts of counts),  
since summary on a factor is just the same as table on a factor, so a  
further table operation was giving me a set of weeks that shared the  
same number of counts in the original dataset (which may not be the  
best thing to work with as an example if it has sum(Weeks) = 34377  
entries):

 > wk2 <- Sys.Date() -round(150*runif(150))

 > options(width=60)
 > summary(wk2)
         Min.      1st Qu.       Median         Mean
"2009-07-02" "2009-08-10" "2009-09-20" "2009-09-18"
      3rd Qu.         Max.
"2009-10-27" "2009-11-28"
 > table(summary(cut(wk2, breaks="weeks")))

  1  2  3  4  5  6  7  9 11 12 14
  1  1  2  1  5  2  1  5  2  1  1
 > table(table(cut(wk2, breaks="weeks")))

  1  2  3  4  5  6  7  9 11 12 14
  1  1  2  1  5  2  1  5  2  1  1
 > summary(cut(wk2, breaks="weeks"))
2009-06-29 2009-07-06 2009-07-13 2009-07-20 2009-07-27
          1          9          5          4         12
2009-08-03 2009-08-10 2009-08-17 2009-08-24 2009-08-31
          6          9          5          5          5
2009-09-07 2009-09-14 2009-09-21 2009-09-28 2009-10-05
          3         14          5          2          6
2009-10-12 2009-10-19 2009-10-26 2009-11-02 2009-11-09
          7         11          9         11          9
2009-11-16 2009-11-23
          9          3
 > table(cut(wk2, breaks="weeks"))

2009-06-29 2009-07-06 2009-07-13 2009-07-20 2009-07-27
          1          9          5          4         12
2009-08-03 2009-08-10 2009-08-17 2009-08-24 2009-08-31
          6          9          5          5          5
2009-09-07 2009-09-14 2009-09-21 2009-09-28 2009-10-05
          3         14          5          2          6
2009-10-12 2009-10-19 2009-10-26 2009-11-02 2009-11-09
          7         11          9         11          9
2009-11-16 2009-11-23
          9          3
David Winsemius, MD
Heritage Laboratories
West Hartford, CT