r - Group dates by bimester -


Here's a sample of data, on which I'm currently working:

  x & lt; - Structure (list (secs = C (0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = C (59 L, 32 L, 23 L, 26 L, 20 L , 14 L, 1 L, 5 L, 32 L, 2 L), Hour = C (10 L, 15 L, 12 L, 12 L, 16 L, 18 L, 18 L, 9 L, 14 L, 12 L ), MAD = C (9L, 15L, 2L, 15L, 20L, 26L, 11L, 22L, 9L, 16L), Mon = C (4L, 11L, 10L, 7 L, 9 L, 8 L, 10 L, 8 L, 8 L, 4 L), Year = C (111 L, 111 L, 111 L, 111 L, 111 L, 111 L, 111 L, 111 L, 111 L, 111 L), wday = C (1 L, 4 L, 3 L, 1 L, 4 L, 1 L, 5 L, 4 L, 5 L, 1 L), Yd = C (128 L, 348 L, 305 L, 226 L, 292 L, 268 L, 314 L, 264 L ("seconds", "minute", "hour", "25", "l", "LCD", "  

This is because" Monday "," Mon " , "Year", "wday", "yday", "isdst"), class = c ("POSIXlt", "POSIXt"))

 > X [1] "2011 -05-09 10:59:00 "" 2011-12-15 15:32:00 "" 2011-11-02 12:23:00 "[4]" 2011-08-15 12: 26: 00 "" 2011-10-20 16:20:00 "" 2011-09-26 18:14:00 "[7]" 2011-11-11 18:01:00 "" 2011-09-22 09:05:00 " "2011-09-09 14:32:00" [10] "2011-05-16 12:02:00"   

Say I can do this by tablet month by x How do I complete delivery of :

  & gt; The table (striptime (x, '% m')) 05 08 09 10 11 12 2 1 3 1 2 1   

Now I want to do the same tabulation, but at the moment I want to Data by the bimaster to the group (and possibly by the trimester or semester, later). I have taken a look but could not find a suitable separator.

This is the best I have ever done:

  & gt; Table (cut (x = as.numeric (strftime (x, '% m')), broken = C (1, 3, 5, 7, 9, 11, 13), label = c ('1-2' '3-4', '5-6', '7-8', '9-10', '11 -12 '), true = false) 1-2 3-4 5-6 7-8 9- 10 11-12 0 0 2 1 4 3 This is a complicated way to reach it, but this is a simple example and is fine for the same case. But I will feel that the data will remain POSIX (not to mention that it should be scary as my code should be). Is this a beautiful   

If you select table and vectors (as a rectangular data / Output is opposed to, in which case I use data.table , you can:

  table (2 * (x) $ Mon% /% 2) + 1) # 5 7 9 11 # 2 1 4 3    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -