Description Usage Arguments Details Value Note Author(s) Examples
running count of occurences for each unique value in a vector
1 | runningCount(x)
|
x: |
integer vector |
For an integer vector, returns a vector of equal length giving the number of times the i'th element occurs in the first i slots.
integer vector rv
; rv[i] =
sum(x[1:i] == x[i])
: despite the O(log(length(x))) call to order()
,
this works faster up to at least length(x) == 1E8 than a similar
version that first converts to a factor and then orders using
method="radix"
John Brzustowski jbrzusto@REMOVE_THIS_PART_fastmail.fm
1 2 3 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.