i have vector v , want have vector w weight of each element of v. how can result (vector w)in r? example,
v = c(0, 0, 1, 1, 1, 3, 4, 4, 4, 4, 5, 5, 6) u = unique(v) w = c(2, 3, 1, 4, 2, 1)
use table:
table(v) v 0 1 3 4 5 6 2 3 1 4 2 1
Comments
Post a Comment