Stefano Sofia wrote on 11/03/2011 11:28:08 AM:
> 
> Dear R users,
> I have got the following data frame, called my_df:
> 
>    gender day_birth month_birth year_birth labour
> 1           F             22                  10           2001 1
> 2           M            29                  10           2001 2
> 3           M              1                   11          2001 1
> 4           F               3                  11           2001  1
> 5           M              3                  11           2001 2
> 6           F              4                   11           2001  1
> 7           F              4                   11           2001  2
> 8           F              5                   12           2001  2
> 9           M           22                   14           2001 2
> 10         F           29                   13           2001          2
> ...
> 
> I need to count data in different ways:
> 
> 1. count the births for each day (having 0 when necessary) 
> independently from the value of the "labour" column
> 
> 2. count the births for each day (having 0 when necessary), divided 
> by the value of "labour" (which can have two valuers, 1 or 2)
> 
> 3. count the births for each day of all the years (i.e. the 22nd of 
> October of all the years present in the data frame) independently 
> from the value of "labour"
> 
> 4. count the births for each day of all the years (i.e. the 22nd of 
> October of all the years present in the data frame), divided by the 
> value of "labour"
> 
> I tried with the command
> 
> table(my_df$year_birth, my_df$month_birth, my_df$day_birth)
> 
> which satisfies (partially) question numer 1 (I am not able to have 
> 0 in the not available days).
> 
> Is there a smart way to do that without invoking too many loops?
> 
> thank you for your help
> Stefano Sofia
> 

I'm having a hard time understanding what you're trying to calculate.  Can 
you show us what the results would look like from the example data you 
shared?

Jean
	[[alternative HTML version deleted]]

