say 'dat' is your data frame, then one way is the following:
f <- factor(dat$Id, levels = unique(dat$Id))
dat$Number <- unclass(f)
dat
I hope it helps.
Best,
Dimitris
clion wrote:
Dear R users,
my dataframe looks like this
head(dat)
Id sex byear age
1 300 m 2003 50
2 300 m 2003
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 402f 2003 29
4 402f 2003 21
5 402f 2003 64
6 150 m 2005 43
...
...(where Id is just the Identification number of Individual, sex (male or
female), byear (=birth
2 matches
Mail list logo