Message-ID: <1345846985.86707.YahooMailNeo@web171405.mail.ir2.yahoo.com>
Date: 2012-08-24T22:23:05Z
From: Sepp Tannhuber
Subject: extract vector elements of unknown range
Dear all,
I have two vectors
? x <- c(1:20)
? y <- c(1,5,10,14)
Now I would like to extract
? x[ (y[n] + 2):(y[n+1] - 1) ]
for all elements except last one in y. This means I want to have
??x[ c( (y[1]+2):(y[2]-1), (y[2]+2):(y[3]-1), (y[3]+2):(y[4]-1) ) ]
How is this possible if y is a vector of unknown length?
Best regards
Joseph