Re: [R] enumeration variable by groups
Here is a way to do it: > x <- scan(textConnection("1 48 1 45 2 50 2 42 1 41 2 51 1 52 1 43 2 > 52"), what=0L) Read 18 items > x <- matrix(x, ncol=2, byrow=TRUE) > colnames(x) <- c('gender', 'score') > x gender score [1,] 148 [2,] 145 [3,] 250 [4,]
[R] enumeration variable by groups
Dear all, How can I create an enumeration variable by groups? I have: gender score 1 48 1 45 2 50 2 42 1 41 2 51 1 52 1 43 2 52 and Y would like to get: genderscoreindex 148 1 145 2 141 3