Message-ID: <20090429102623.GA10102@localhost>
Date: 2009-04-29T10:26:23Z
From: Philipp Pagel
Subject: selecting ith rows of a matrix
In-Reply-To: <ffa653cd0904290128l1491f7b0ne0f4f71faa984527@mail.gmail.com>
On Wed, Apr 29, 2009 at 01:58:06PM +0530, Umesh Srinivasan wrote:
> Hi all,
>
> If I have a huge matrix/ dataframe and I want to create a new matrix/
> dataframe with every second (or third, or fourth etc.) row of the original
> matrix, how can I do it? Any help much appreciated.
Others ahve already poitned out soltions using seq9(). I'd just like
to add an alternative approach making use of R's logical indexing and
recycling rules:
mat <- matrix(1:1000, 100, 5)
mat2 <- mat[c(T,F),]
cu
Philipp
--
Dr. Philipp Pagel
Lehrstuhl f?r Genomorientierte Bioinformatik
Technische Universit?t M?nchen
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel