[R] "autonumber" for grouping variable
clion
birte_2 at hotmail.com
Mon Feb 23 16:22:27 CET 2009
Dear R users,
my dataframe looks like this
head(dat)
Id sex byear age
1 300 m 2003 50
2 300 m 2003 36
3 402 f 2003 29
4 402 f 2003 21
5 402 f 2003 64
6 150 m 2005 43
...
...(where Id is just the Identification number of Individual, sex (male or
female), byear (=birthyear))
now, I 'd like to add a column, where each Individual gets an automated
number starting from 1, so that I can number them consecutively
something which should look like this:
Id sex byear age Number
1 300 m 2003 50 1
2 300 m 2003 36 1
3 402 f 2003 29 2
4 402 f 2003 21 2
5 402 f 2003 64 2
6 150 m 2005 43 3
...
...
how can I easily do this?
thanks a lot for any help,
Birte
--
View this message in context: http://www.nabble.com/%22autonumber%22-for-grouping-variable-tp22163546p22163546.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list