Skip to content
Back to formatted view

Raw Message

Message-ID: <CAAmySGNsBZ3nkdCu32+LUDdf+iA0Eo0ttwxj7nY9PmgKSi11Jw@mail.gmail.com>
Date: 2012-09-18T14:58:31Z
From: R. Michael Weylandt
Subject: extracting column and regular interval in R
In-Reply-To: <BLU150-W32CDB75E6FAEE468C10F3289940@phx.gbl>

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.