s-news
[Top] [All Lists]

Re: detecting repeated values in a vector

To: Caitlin Burgess <caitlin@cbr.washington.edu>
Subject: Re: detecting repeated values in a vector
From: Patrick Burns <pburns@pburns.seanet.com>
Date: Thu, 04 May 2006 21:46:15 +0100
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <Pine.SOL.4.10.10605041321550.23712-100000@grebe>
References: <Pine.SOL.4.10.10605041321550.23712-100000@grebe>
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
Sounds like a job for 'rle'.

Patrick Burns
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Caitlin Burgess wrote:


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

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



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