Skip to content

Repeated Indexing / Sequence Operation

5 messages · Paolo Rossi, Duncan Murdoch, Gabor Grothendieck +1 more

#
On 31/12/2010 1:03 PM, Paolo Rossi wrote:
How about this:

SampleWidth <- 5
samples <- (-SampleWidth):SampleWidth
i2 <- c(90, 190, 290)
i3 <- as.vector(outer(samples, i2,  "+"))

Duncan Murdoch
#
On Fri, Dec 31, 2010 at 1:03 PM, Paolo Rossi
<statmailinglists at googlemail.com> wrote:
Try this:

n <- 5
c(sapply(i2, function(x) seq(x - n, x + n)))
#
On Fri, 31 Dec 2010, Paolo Rossi wrote:

            
For heavy duty applications involving intervals - many intervals, finding 
overlapping intervals, set operations, et cetera, you may want to use the 
IRanges package:

http://www.bioconductor.org/help/bioc-views/release/bioc/html/IRanges.html
Like this:
[1]  85  86  87  88  89  90  91  92  93  94  95 185 186 187 188 189 190 191 192
[20] 193 194 195 285 286 287 288 289 290 291 292 293 294 295
HTH,

Chuck
Charles C. Berry                            Dept of Family/Preventive Medicine
cberry at tajo.ucsd.edu			    UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901