my database is:
Time Sex Weight Time.midnight
0005 1 3837 5
0104 1 3334 64
0118 2 3554 78
0155 2 3838 115
0257 2 3625 177
0405 1 2208 245
0407 1 1745 247
0422 2 2846 262
0431 2 3166 271
0708 2 3520 428
0735 2 3380 455
0812 2 3294 492
0814 1 2576 494
which contains the time of birth, sex, and birth weight for babies born in one 24-hour period at hospital. The variables are the following:
Time: Time of birth recorded on the 24-hour clock / Sex: sex of the child(1=girl,2=boy) / Weight: birth weight in grams / Time.midnight: number of minutes after midnight of each birth
now I want to calculate what is the proportion of girls with a weight smaller than 3 kg ? Compare with the corresponding proportion for boys?
I wanted to use by() function, but below command returned error.
by(Weight, Sex, length(which(Weight<3000)))
Could you please guide?