[R] Lining up x-y datasets based on values of x

2007-02-01 Thread Christos Hatzis
Hi, I was wondering if there is a direct approach for lining up 2-column matrices according to the values of the first column. An example and a brute-force approach is given below: x - cbind(1:10, runif(10)) y - cbind(5:14, runif(10)) z - cbind((-4):5, runif(10)) xx - seq(

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Marc Schwartz
On Thu, 2007-02-01 at 15:05 -0500, Christos Hatzis wrote: Hi, I was wondering if there is a direct approach for lining up 2-column matrices according to the values of the first column. An example and a brute-force approach is given below: x - cbind(1:10, runif(10)) y - cbind(5:14,

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Christos Hatzis
:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 3:29 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Lining up x-y datasets based on values of x On Thu, 2007-02-01 at 15:05 -0500, Christos Hatzis wrote: Hi, I was wondering if there is a direct approach for lining up 2

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Marc Schwartz
On Thu, 2007-02-01 at 15:45 -0500, Christos Hatzis wrote: Thanks Marc and Phil. My dataset actually consists of 50+ individual files, so I will have to do this one column at a time in a loop... I might look into SQL and outer joints as an alternative to avoid looping. Thanks again.

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Marc Schwartz
: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 4:21 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Lining up x-y datasets based on values of x On Thu, 2007-02-01 at 15:45 -0500, Christos Hatzis wrote: Thanks Marc and Phil. My dataset

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Christos Hatzis
- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 4:21 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Lining up x-y datasets based on values of x On Thu, 2007-02-01 at 15:45 -0500, Christos Hatzis wrote: Thanks Marc and Phil. My dataset

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Prof Brian Ripley
x-y datasets based on values of x On Thu, 2007-02-01 at 15:45 -0500, Christos Hatzis wrote: Thanks Marc and Phil. My dataset actually consists of 50+ individual files, so I will have to do this one column at a time in a loop... I might look into SQL and outer joints as an alternative to avoid

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Gabor Grothendieck
The zoo package has a multiway merge with optional zero fill. Here are two ways: library(zoo) merge(x = zoo(x[,2], x[,1]), y = zoo(y[,2], y[,1]), z = zoo(z[,2], z[,1]), fill = 0) # or library(zoo) X - list(x = x, y = y, z = z) merge0 - function(..., fill = 0) merge(..., fill =

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Marc Schwartz
On Thu, 2007-02-01 at 23:34 +, Prof Brian Ripley wrote: On Thu, 1 Feb 2007, Marc Schwartz wrote: Christos, Haccording to the Value section in ?merge: A data frame. The rows are by default lexicographically sorted on the common columns, but for sort=FALSE are in an

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Christos Hatzis
@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Lining up x-y datasets based on values of x On Thu, 2007-02-01 at 23:34 +, Prof Brian Ripley wrote: On Thu, 1 Feb 2007, Marc Schwartz wrote: Christos, Haccording to the Value section in ?merge: A data frame. The rows are by default

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Christos Hatzis
Thanks again. -Christos -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 7:25 PM To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Lining up x-y datasets based on values of x The zoo package has a multiway merge

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Marc Schwartz
On Thu, 2007-02-01 at 22:46 -0500, Christos Hatzis wrote: Marc, I don't think the issue is duplicates in the matching columns. The data were generated by an instrument (NMR spectrometer), processed by the instrument's software through an FFT transform and other transformations and finally

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Christos Hatzis
. -Christos -Original Message- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 11:06 PM To: [EMAIL PROTECTED] Cc: 'Prof Brian Ripley'; r-help@stat.math.ethz.ch Subject: Re: [R] Lining up x-y datasets based on values of x On Thu, 2007-02-01 at 22:46 -0500, Christos

Re: [R] Lining up x-y datasets based on values of x

2007-02-01 Thread Marc Schwartz
] Sent: Thursday, February 01, 2007 11:06 PM To: [EMAIL PROTECTED] Cc: 'Prof Brian Ripley'; r-help@stat.math.ethz.ch Subject: Re: [R] Lining up x-y datasets based on values of x On Thu, 2007-02-01 at 22:46 -0500, Christos Hatzis wrote: Marc, I don't think the issue is duplicates