Re: [R] Extracting only odd columns from a matrix

2011-03-09 Thread Bill.Venables
Xonly <- XY[, grep("^X", dimnames(XY)[[2]])] -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nixon, Matthew Sent: Thursday, 10 March 2011 12:20 AM To: r-help@R-project.org Subject: [R] Extracting only odd columns from a matrix H

Re: [R] Extracting only odd columns from a matrix

2011-03-09 Thread Henrique Dallazuanna
Try this: m <- matrix(rnorm(12), ncol = 4) m[,c(FALSE, TRUE)] On Wed, Mar 9, 2011 at 11:20 AM, Nixon, Matthew wrote: > Hi, > > This might seem like a simple question but at the moment I am stuck for > ideas. The columns of my matrix in which some data is stored are of this > form: > > X1 Y1

Re: [R] Extracting only odd columns from a matrix

2011-03-09 Thread rex.dwyer
11 9:36 AM To: Nixon, Matthew Cc: r-help@R-project.org Subject: Re: [R] Extracting only odd columns from a matrix one way is using the seq(), e.g., say 'm' is your matrix, then try: m[, seq(1, ncol(m), by = 2)] I hope it helps. Best, Dimitris On 3/9/2011 3:20 PM, Nixon, Matthew wrote:

Re: [R] Extracting only odd columns from a matrix

2011-03-09 Thread Dimitris Rizopoulos
one way is using the seq(), e.g., say 'm' is your matrix, then try: m[, seq(1, ncol(m), by = 2)] I hope it helps. Best, Dimitris On 3/9/2011 3:20 PM, Nixon, Matthew wrote: Hi, This might seem like a simple question but at the moment I am stuck for ideas. The columns of my matrix in which

Re: [R] Extracting only odd columns from a matrix

2011-03-09 Thread Sarah Goslee
oddvals <- seq(1, ncol(mydata), by=2) mydata[,oddvals] On Wed, Mar 9, 2011 at 9:20 AM, Nixon, Matthew wrote: > Hi, > > This might seem like a simple question but at the moment I am stuck for > ideas. The columns of my matrix in which some data is stored are of this form: > > X1     Y1     X2