Skip to content
Prev 305788 / 398506 Next

extracting column at regular intervals starting from different columns

On 18-09-2012, at 19:21, eliza botto wrote:

            
When you use my method you could do the following

f3 <- function(x,M,start=1) {
    x[c(start,seq_len((length(x)-1)/M)*M+start)]
}

M <- 37
A <- 1:(3*M)
f3(A,M)
f3(A,M,start=1)
f3(A,M,start=2)

When start is too large you may get NA's in the result.
You may have to get rid of them.

Berend