Skip to content
Prev 25249 / 398502 Next

[Newbie] Is there any support for work with grouped frequencies?

On Wed, Nov 13, 2002 at 07:16:32PM +0100, Christian Schulz wrote:
I do not think, that it makes any sense to take mean from one
value of every valuable (which is what I do with tapply here,
don't I?).

	Matej

	> tab
					  LABEL FREQ MIDPOINT
	1  Infant (under 1)    0      1.0
	2            1 to 4    5      2.5
	3            5 to 8    1      6.5
	4           9 to 12    3     10.5
	5          13 to 16    0     14.5
	6          17 to 19    3     18.0
	7          20 to 24  117     22.0
	8          25 to 29  341     27.0
	9          30 to 34  503     32.0
	10         35 to 39  578     37.0
	11         40 to 44  510     42.0
	12         45 to 49  369     47.0
	13         50 to 54  272     52.0
	14         55 to 59  177     57.0
	15         60 to 64   79     62.0
	16         65 to 69   29     67.0
	17         70 to 74   15     72.0
	18      75 and over   11     75.0
	19          Unknown   NA       NA
	>
	> tapply(tab$FREQ,tab$LABEL,mean)
	Infant (under 1)          Unknown           1 to 4         13 to
	16
						0               NA
	5                0
			  17 to 19         20 to 24         25 to 29         30 to
	34
						3              117              341
	503
			  35 to 39         40 to 44         45 to 49           5 to
	8
					 578              510              369
	1
			  50 to 54         55 to 59         60 to 64         65 to
	69
					 272              177               79
	29
			  70 to 74      75 and over          9 to 12
					  15               11                3