[R] Recode numbers

Lisa lisajca at gmail.com
Wed Jun 1 21:27:58 CEST 2011


Thank you, Duncan,

Here “a” has the length of 24, and “b” has the length of 20 with numbers
from 1 to 20 uniquely. I just want encode “a” from 1 to 20 based on “a”
current order using “b”. So, a1[1] = b[1] = 1
a1[2] = b[2] = 5
a1[3] = a1[4] = b[3] = 8 (since third and fourth numbers are the same in
“a”)
a1[5] = a1[6] = b[4] = 9
a1[7] = b[5] = 14
a1[8] = b[6] = 20
a1[9] = b[7] = 3
a1[10] = a1[11] = b[8] = 10
...
a1[23] = b[19] = 15
a1[24] = b[20] = 19


--
View this message in context: http://r.789695.n4.nabble.com/Recode-numbers-tp3566395p3566681.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list