r - matrix containing number of occurrence corresponding to each element in the matrix -


i have matrix, suppose

a = [1 2 3 1 1 1 2 3] 

i want find number of times number appeared in matrix. output matrix i/p

b = [1 1 1 2 3 4 2 2] 

i.e. 1 appeared 4 times in array, hence last value corresponding 1 4.

unique , sum unique not because gives total number of times element occured, want matrix increases count every time occurs.

try this:

b = ave(a,a,fun=function(x) 1:length(x)) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -