[R] Creating Enumerated Variables

jdellava jdellava at vcu.edu
Thu Jul 15 16:45:57 CEST 2010


Hi,

I am trying to create a variable counting the number of individuals based on
two variables. I am able to do it or one variable, but not two. In SAS I was
able to sort by two variables and use a first. statement to create the
counts based on both. Here is an example:

What I have
ID	Age		School		Grade	
1	10		1			98
2	10		2			97
3	10		1			92
4	11		1			90
5	11		1			80
6	11		2			70	
7	10		1			80	
8	10		1			79
9	11		2			70

What I need
ID	Age		School		Grade 	School Count
1	10		1			98		1
3	10		1			92		2
7	10		1			80		3
8	10		1			79		4
2	10		2			97		1
4	11		1			90		1
5	11		1			80		2
6	11		2			70		1
9	11		2			70		2

I want to create counts of individuals age 10 in school 1 then age 10 in
school two (the what I need set)

Anyway to do this?

Thank you.

-- 
View this message in context: http://r.789695.n4.nabble.com/Creating-Enumerated-Variables-tp2290262p2290262.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list