[R] Grouping data

From: K. Elo <maillists_at_nic.fi>
Date: Wed, 16 Jan 2008 22:06:23 +0200


Hi,

I am quite new to R (but like it very much!), so please apologize if this is a too simple question.

I have a large data frame consisting of data from a survey. There is, for example, information about age and education (a numeric value from 1-9). Now I would like to extract the total amount of each type of education within different age groups (e.g. from 18 to 25, from 25 to 35 etc.). How could I achieve this? (I have been thinking about using 'subset', but if there are better ideas they are welcome :) )

An example might clarify my point. Let's assume the following data:

#	age	edu
1	25	2
2	33	5
3	22	3
4	19	1
5	21	3
6	30	4
7	32	4
8	31	1

What I want to have is:

edu	18-25	25-35 ...
1	1	1
2	1	0
3	2	0
4	0	2
5	0	1

Thanks in advance & kind regards,
Kimmo



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 16 Jan 2008 - 20:10:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jan 2008 - 15:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive