Re: [R] extract rows of a matrix

2010-10-13 Thread Greg Snow
> newmat <- oldmat[ c(rep(FALSE,19),TRUE), ]

Or

> newmat <- oldmat[ seq(20, nrow(oldmat), 20), ]


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of li li
> Sent: Tuesday, October 12, 2010 2:00 PM
> To: r-help
> Subject: [R] extract rows of a matrix
> 
> Hi all,
>   I want to extract every 20th row of a big matrix, say 1 by 1000.
> What is the simper way to do this?
>Thank you very much!
> Hannah
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@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.

__
R-help@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.


Re: [R] extract rows of a matrix

2010-10-12 Thread Jonathan Christensen
Hannah,

a <- matrix(rnorm(1),nrow=500)
new.matrix <- a[seq(0,dim(a)[1],by=20),]

Jonathan


On Tue, Oct 12, 2010 at 1:59 PM, li li  wrote:
> Hi all,
>  I want to extract every 20th row of a big matrix, say 1 by 1000.
> What is the simper way to do this?
>   Thank you very much!
>            Hannah
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@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.
>

__
R-help@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.