Re: [R] merging and obtaining the nearest value

2012-08-20 Thread Francesco
---Original Message- > > From: Rui Barradas [mailto:ruipbarra...@sapo.pt] > > Sent: Sunday, August 19, 2012 3:54 PM > > To: William Dunlap; Francesco > > Cc: r-help > > Subject: Re: [R] merging and obtaining the nearest value > > > > Hello, > > >

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread William Dunlap
TIBCO Software wdunlap tibco.com > -Original Message- > From: Rui Barradas [mailto:ruipbarra...@sapo.pt] > Sent: Sunday, August 19, 2012 3:54 PM > To: William Dunlap; Francesco > Cc: r-help > Subject: Re: [R] merging and obtaining the nearest value > > Hello, > >

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread Rui Barradas
} Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Sunday, August 19, 2012 1:49 PM To: Francesco; r-help@r-project.org Subject: Re: [R] merging and o

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread William Dunlap
t.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of William Dunlap > Sent: Sunday, August 19, 2012 1:49 PM > To: Francesco; r-help@r-project.org > Subject: Re: [R] merging and obtaining the nearest value > > The following, f2(A,B), should do well with lots of rows in A

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread William Dunlap
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of William Dunlap > Sent: Sunday, August 19, 2012 9:43 AM > To: Francesco; r-help@r-project.org > Subject:

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread Rui Barradas
.@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Sunday, August 19, 2012 3:52 AM To: Francesco Cc: r-help Subject: Re: [R] merging and obtaining the nearest value Hello, Try the following. A <- read.table(text=" TYPE DATE A2 A

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread William Dunlap
p-boun...@r-project.org] On > Behalf > Of Francesco > Sent: Sunday, August 19, 2012 4:01 AM > To: r-help@r-project.org > Subject: Re: [R] merging and obtaining the nearest value > > Dear Riu, Many thanks for your suggestion > > However these are just simplified exa

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread Francesco
Thank you very much Rui On 19 August 2012 13:49, Rui Barradas wrote: > Hello, > > Yes you can, if you have memory problems, say so and we'll see it then. > In the mean time, there's something you should change, to allow for several > minima but to only return one per combination of TYPE and DATE

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread Rui Barradas
Hello, Yes you can, if you have memory problems, say so and we'll see it then. In the mean time, there's something you should change, to allow for several minima but to only return one per combination of TYPE and DATE. Replace this x[which(min(a) == a), ] by this x[which.min(a), ] Rui Bar

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread Francesco
Dear Riu, Many thanks for your suggestion However these are just simplified examples... in reality the dataset A contains millions of observations and B several thousands of rows... Could I still use a modified form of your suggestion? Thanks On 19 August 2012 12:51, Rui Barradas wrote: > Hello

Re: [R] merging and obtaining the nearest value

2012-08-19 Thread Rui Barradas
Hello, Try the following. A <- read.table(text=" TYPE DATE A2 A5 A20 B10 B2 ", header = TRUE) B <- read.table(text=" TYPE Special_Date A 2 A 6 A 20 A 22 B 5 B

[R] merging and obtaining the nearest value

2012-08-19 Thread Francesco
Dear R-help Î would like to know if there is a short solution in R for this merging problem... Let say I have a dataset A as: TYPE DATE A2 A5 A20 B10 B2 (there can be duplicates for the same type and date) and I have another dataset