[R] help with vector construction

Greg Snow Greg.Snow at intermountainmail.org
Thu Jul 5 22:07:47 CEST 2007

One approach is to use the fact that vectors are automatically
replicated to the correct length when subscripting, so you can do
something like:

> my.matrix[ c(FALSE,TRUE,FALSE), 3 ] 

To get every 3rd element starting at the 2nd element, and the 3rd

Hope this helps,

Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Juan 
> Pablo Fededa
> Sent: Thursday, July 05, 2007 11:30 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] help with vector construction
> Hi all,
> I want to make a vector with the third column of a matrix, 
> but only for the
> 2+3n rows of the matrix, with n being an entire number from 0 
> to a million.
> How can I do that in an easy way?
> Thanks in advance,
> Juan Pablo
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch 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