| To: | Dave Evens <devens8765@yahoo.com> |
|---|---|
| Subject: | Re: finding substrings |
| From: | David L Lorenz <lorenz@usgs.gov> |
| Date: | Tue, 13 Sep 2005 08:51:49 -0500 |
| Cc: | s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu |
| In-reply-to: | <20050913092327.19791.qmail@web61324.mail.yahoo.com> |
|
Dave, This is probably best done by using the ability of aggregateSeries to compute running statistics. I did not make this a generic function, but with some work, that could be done. Here's the concrete example: aggregateSeries(timeSeries(c(F, F, F, T, T, F, F, T, T, F, F, T, T, T, F, F, F, F, F, T, T, T, F, F, T, T, F, F, T, T, T), pos=1:31) ,moving=5,FUN=function(x) all(x == c(F, F, T, T, F)))@data The idea is to create a timeSeries object of relative time, do a moving computation of length = the length of the test vector, and extract the data, which is a logical vector of length 31 - 5 + 1 (in this case). The index numbers that you want can be gotten by using which. Note that most everything can be converted to a timeSeries object (numeric, logical, character, factor, more?). Dave
Dear all, I would like to find the exact match of a substring(/sub-vector) within a string (/vector). For example, suppose I have x <- c(F, F, F, T, T, F, F, T, T, F, F, T, T, T, F, F, F, F, F, T, T, T, F, F, T, T, F, F, T, T, T) y <- c(F, F, T, T, F) What I would like to do is find the exact match of y in x with possible overlapping, i.e. return back 2 6 23 I couldn't get it to work with matchList. Thanks for any help in advance. Dave __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com -------------------------------------------------------------------- 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> |
|---|---|---|
| ||
| Previous by Date: | Funny bug-ish interaction between Excel and S-Plus when importing a file, Olivier Renaud |
|---|---|
| Next by Date: | Any S-plus/R doc or manual for SAS user out there?, paul king |
| Previous by Thread: | Re: finding substrings, Dimitris Rizopoulos |
| Next by Thread: | Funny bug-ish interaction between Excel and S-Plus when importing a file, Olivier Renaud |
| Indexes: | [Date] [Thread] [Top] [All Lists] |