conticnt {xefun} | R Documentation |
continuous counting
Description
It counts the number of continuous identical values.
Usage
conticnt(x, cnt = FALSE, ...)
Arguments
x |
a vector or data frame. |
cnt |
whether to count the number rows in each continuous groups. |
... |
ignored |
Value
A integer vector indicating the number of continuous identical elements in x.
Examples
# example I
x1 = c(0,0,0, 1,1,1)
conticnt(x1)
conticnt(x1, cnt=TRUE)
x2 = c(1, 2,2, 3,3,3)
conticnt(x2)
conticnt(x2, cnt=TRUE)
x3 = c('c','c','c', 'b','b', 'a')
conticnt(x3)
conticnt(x3, cnt=TRUE)
# example II
dt = data.frame(c1=x1, c2=x2, c3=x3)
conticnt(dt, col=c('c1', 'c2'))
conticnt(dt, col=c('c1', 'c2'), cnt = TRUE)
[Package xefun version 0.1.5 Index]