search for: cetnost

Displaying 1 result from an estimated 1 matches for "cetnost".

Did you mean: cetnos
2003 Nov 14
2
bad performance of a function
...ll I need to find a length of true sequences in logical vector (see example 1). I found a possible solution which is good but if I use it on a larger data set I experience a substantial decrease in performance (example 2). Example 1 set.seed(111) x <- sample(c(T,F),50, replace=T) system.time(cetnost <- as.numeric(table(which(x)-cumsum(x[which(x)])))) [1] 0.00 0.00 0.03 NA NA cetnost [1] 1 3 2 5 1 4 1 1 1 3 1 1 2 Example 2 x<-sample(c(T,F),40321*51, replace=T) dd<-matrix(x,40321,51) system.time(cetnost <- lapply(dd,function(x) as.numeric(table(which(x)- cumsum(x[which(x)])))))...