s-news
[Top] [All Lists]

detecting repeated values in a vector

To: s-news@lists.biostat.wustl.edu
Subject: detecting repeated values in a vector
From: Caitlin Burgess <caitlin@cbr.washington.edu>
Date: Thu, 4 May 2006 13:27:54 -0700 (PDT)
 
Hello,

I'm trying to detect repeated values of length k in a vector of
measurements (a stuck sensor). I was thinking of something like

 
for (val in 1:(length(vector)-k+1)) {
 
    if ( vector[val:(val+k)] == rep(vector[val],k) ) {#detection positive}
 
}
 
It's a long vector and there are many of them though... Is there a better
way?
 
Thanks for help,
 
Caitlin


<Prev in Thread] Current Thread [Next in Thread>