[R] extracting column and regular interval in R

R. Michael Weylandt michael.weylandt at gmail.com
Tue Sep 18 16:58:31 CEST 2012


x[c(TRUE, rep(FALSE, 36)),]

and let recycling work its magic!

To concretize:

x <- 1:100

x[c(TRUE, rep(FALSE, 4))]

Cheers,
Michael

On Tue, Sep 18, 2012 at 3:55 PM, eliza botto <eliza_botto at hotmail.com> wrote:
>
> Dear R users,
> i have a matrix with 31 rows and 444 columns and i want to extract every 37th column of that matrix starting from 1. more precisely i want to select columns 1, 38,75, 112 and so on. then doing the same by starting from column number 2(2,39,76,113.......).
> i know that there is a manual way of doing it but i wanted to make it more quickly as i have fairly large data to dealth with.
>
> thanks in advance
> eliza
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list