Re: [R] Merge data by coordinates

2016-10-18 Thread Michal Kubista
Dear Milu, If your objective is to match the places from one table to the nearest place in the second table, you can generally use knn algorithm for 1 nearest neighbourhood. But please, check what David suggests first. Best regards, Michal 2016-10-16 19:24 GMT+02:00 David Winsemius

Re: [R] Merge data by coordinates

2016-10-16 Thread David Winsemius
> On Oct 16, 2016, at 6:32 AM, Miluji Sb wrote: > > Dear all, > > I have two dataframe 1 by latitude and longitude but they always do not > match. Is it possible to merge them (e.g. nearest distance)? > > # Dataframe 1 > structure(list(lat = c(54L, 55L, 51L, 54L, 53L, 50L,

[R] Merge data by coordinates

2016-10-16 Thread Miluji Sb
Dear all, I have two dataframe 1 by latitude and longitude but they always do not match. Is it possible to merge them (e.g. nearest distance)? # Dataframe 1 structure(list(lat = c(54L, 55L, 51L, 54L, 53L, 50L, 47L, 51L, 49L, 54L), lon = c(14L, 8L, 15L, 7L, 6L, 5L, 13L, 5L, 13L, 11L ), PPP2000_40

[R] Merge data frame with mispelling characters

2012-11-02 Thread VictorDelgado
Hello dear R-helpers, I'm working with R-2.15.2 on Windows 7 OS. I'm stucked with a merge of two data frames by characters. In each data frame I got two different list of names, that is my main-key to be merged. To figure out what I'm saying, I build up a modified ?merge example, with errors by

Re: [R] Merge data frame with mispelling characters

2012-11-02 Thread jim holtman
You might try the 'soundex' function in the RecordLinkage package: soundex('ripley') [1] R140 soundex('rippley') [1] R140 soundex('venable') [1] V514 soundex('venables') [1] V514 soundex('terney') [1] T650 soundex('tierney') [1] T650 On Fri, Nov 2, 2012 at 2:20 PM, VictorDelgado

Re: [R] Merge data frame with mispelling characters

2012-11-02 Thread David Winsemius
On Nov 2, 2012, at 11:20 AM, VictorDelgado wrote: Hello dear R-helpers, I'm working with R-2.15.2 on Windows 7 OS. I'm stucked with a merge of two data frames by characters. In each data frame I got two different list of names, that is my main-key to be merged. To figure out what I'm

Re: [R] Merge data frame with mispelling characters

2012-11-02 Thread VictorDelgado
David Winsemius wrote On Nov 2, 2012, at 11:20 AM, VictorDelgado wrote: Hello dear R-helpers, I'm working with R-2.15.2 on Windows 7 OS. I'm stucked with a merge of two data frames by characters. In each data frame I got two different list of names, that is my main-key to be merged.

[R] Merge Data by time stamps

2011-10-10 Thread Alaios
Dear all, I have some device measurements and the time stamps I get from it have the below format: MyStruct$TimeStamps[1,] [1] 2011.000   10.000    6.000   16.000   23.000   30.539 I can convert them easily with ISOdate() to a number and do the calculations I need. One of my problems is that

Re: [R] Merge Data by time stamps

2011-10-10 Thread David Winsemius
On Oct 10, 2011, at 1:28 PM, Alaios wrote: Dear all, I have some device measurements and the time stamps I get from it have the below format: MyStruct$TimeStamps[1,] [1] 2011.000 10.0006.000 16.000 23.000 30.539 I can convert them easily with ISOdate() to a number and do the

Re: [R] Merge data under conditions

2011-03-13 Thread flymer
Thanks to both of you for your help! Jim, my problem is to match some observations of a time serie (vector 'a' in my example) with theoretical predictions of this process (vector 'b' in my example), with a small time lag between them. -- View this message in context:

[R] Merge data under conditions

2011-03-12 Thread flymer
Dear All, Debuting in R, I'm facing a problem. I have 2 vectors, say 'a' et 'b', and I'd like to merge them according to the proximity of their variable 'time'. How to do to keep elements which satisfy (for example) 'a$time-b$time0.5'? For example : a time x 1 1.0 4 2 2.2 5 3 5.2 6 b

Re: [R] Merge data under conditions

2011-03-12 Thread David Winsemius
On Mar 12, 2011, at 4:14 PM, flymer wrote: Dear All, Debuting in R, I'm facing a problem. I have 2 vectors, say 'a' et 'b', and I'd like to merge them according to the proximity of their variable 'time'. How to do to keep elements which satisfy (for example) 'a$time-b $time0.5'? For

Re: [R] Merge data under conditions

2011-03-12 Thread jim holtman
use the sqldf package: require(sqldf) a time x 1 1.0 4 2 2.2 5 3 5.2 6 b time y 10 1 21 3 32 5 44 7 55 9 sqldf( + select a.time, a.x, b.y + from a, b + where abs(a.time - b.time) 0.5 + ) time x y 1 1.0 4 3 2 2.2 5 5 3 5.2 6 9 On Sat,

Re: [R] Merge Data

2010-11-10 Thread Tal Galili
Hello Nasrin, Please attach how each of your files look like (their first few rows), so we could understand why the rbind doesn't work. In general, be sure to keep the r-help e-mail also corresponded so others might help if I don't know the answer (or if they answer before me). Best, Tal

[R] Merge Data

2010-11-09 Thread Nasrin Pak
Hello; I have a problem merging data sets. I use this command: FileNames - list.files(path=C:/updated_CFL_Rad_files/2007/11, full.names=TRUE) dataMerge - data.frame() for(f in FileNames){ + ReadInMerge - read.csv(file=f, header=T, na.strings=NULL) + dataMerge - merge(dataMerge,

Re: [R] Merge Data

2010-11-09 Thread Tal Galili
Hello Nasrin, I think you might be wanting to use rbind instead of merge Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |

[R] merge data

2009-11-10 Thread Chuck White
df1 -- dataframe with column date and several other columns. #rows 40k Several of the dates are repeated. df2 -- dataframe with two columns date and index. #rows ~130 This is really a map from date to index. I would like to create a column called index in df1 which has the corresponding

Re: [R] merge data

2009-11-10 Thread David Winsemius
On Nov 10, 2009, at 12:36 PM, Chuck White wrote: df1 -- dataframe with column date and several other columns. #rows 40k Several of the dates are repeated. df2 -- dataframe with two columns date and index. #rows ~130 This is really a map from date to index. I would like to create a

Re: [R] merge data

2009-11-10 Thread Chuck White
David -- thank you for your response. merge does work but it creates another dataframe. df1 is very large and I did not want another copy created. What I ended up doing is: df1 - merge(df1, df2, by=week) In terms of memory allocation, will memory for two dataframes be allocated or will the

Re: [R] Merge data frames but prefer values in on

2009-09-14 Thread JiHO
On 2009-September-11 , at 13:55 , wrote: Maybe: do.call(rbind, lapply(with(xy - rbind(x, y), split(xy, list(a, b), drop = TRUE)), tail, 1)) On Fri, Sep 11, 2009 at 3:45 AM, jo jo.li...@gmail.com wrote: Thanks for the post-processing ideas. But is there any way to do that in one step?

Re: [R] Merge data frames but prefer values in on

2009-09-14 Thread Nandi
No you cannot. You may want to write a merge function with the special capability but there is no better way than the one suggested by Henrique. On Sep 14, 12:18 pm, JiHO jo.li...@gmail.com wrote: On 2009-September-11  , at 13:55 ,  wrote: Maybe: do.call(rbind, lapply(with(xy - rbind(x,

Re: [R] Merge data frames but prefer values in one

2009-09-11 Thread jo
Thanks for the post-processing ideas. But is there any way to do that in one step? On Thu, Sep 10, 2009 at 7:20 PM, Henrique Dallazuanna www...@gmail.com wrote: Try this: xy - merge(x, y, by = c(a,b),all = TRUE) xy$c - ifelse(rowSums(!is.na(.x - xy[, c('c.x', 'c.y')])) 1, .x[,1],

Re: [R] Merge data frames but prefer values in one

2009-09-11 Thread Henrique Dallazuanna
Maybe: do.call(rbind, lapply(with(xy - rbind(x, y), split(xy, list(a, b), drop = TRUE)), tail, 1)) On Fri, Sep 11, 2009 at 3:45 AM, jo jo.li...@gmail.com wrote: Thanks for the post-processing ideas. But is there any way to do that in one step? On Thu, Sep 10, 2009 at 7:20 PM, Henrique

[R] Merge data frames but prefer values in one

2009-09-10 Thread JiHO
Hello everyone, My problem is better explained with an example: x=data.frame(a=1:4,b=1:4,c=rnorm(4)) x a b c 1 1 1 -0.8821089 2 2 2 -0.7082583 3 3 3 -0.5948835 4 4 4 -1.8571443 y=data.frame(a=c(1,3),b=3,c=rnorm(2)) y a bc 1 1 3 -0.273155973 2 3 3 0.009517862 Now I

Re: [R] Merge data frames but prefer values in one

2009-09-10 Thread Henrique Dallazuanna
Try this: xy - merge(x, y, by = c(a,b),all = TRUE) xy$c - ifelse(rowSums(!is.na(.x - xy[, c('c.x', 'c.y')])) 1, .x[,1], rowSums(.x, na.rm = TRUE)) xy On Thu, Sep 10, 2009 at 12:21 PM, JiHO jo.li...@gmail.com wrote: Hello everyone, My problem is better explained with an example:

[R] Merge data frames but with a twist.

2009-08-27 Thread Tony Breyal
Dear all, Question: How to merge two data frames such that new column are added in a particular way? I'm not actually sure how to best articulate my question to be honest, so i hope showing you what I want to achieve will communicate my question better. Lets say I have two data frames: DF1 -

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Henrique Dallazuanna
Try this: xtabs(as.numeric(Measure) ~ Show + Datetime, data = DF3) On Thu, Aug 27, 2009 at 8:04 AM, Tony Breyal tony.bre...@googlemail.comwrote: Dear all, Question: How to merge two data frames such that new column are added in a particular way? I'm not actually sure how to best

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Stephen Tucker
class) - Original Message From: Tony Breyal tony.bre...@googlemail.com To: r-help@r-project.org Sent: Thursday, August 27, 2009 4:04:30 AM Subject: [R] Merge data frames but with a twist. Dear all, Question: How to merge two data frames such that new column are added in a particular way

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Gabor Grothendieck
On Thu, Aug 27, 2009 at 9:55 AM, Stephen Tuckerbrown_...@yahoo.com wrote: You may want to use the reshape package for this task: library(reshape) recast(DF3,Show ~ Datetime, id.var=names(DF3),value=Measure)       Show 08/26/2009 11:30 AM 08/26/2009 9:30 AM 1   Firefly                   3    

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Stephen Tucker
To: Stephen Tucker brown_...@yahoo.com Cc: Tony Breyal tony.bre...@googlemail.com; r-help@r-project.org Sent: Thursday, August 27, 2009 7:27:26 AM Subject: Re: [R] Merge data frames but with a twist. On Thu, Aug 27, 2009 at 9:55 AM, Stephen Tuckerbrown_...@yahoo.com wrote: You may want to use the reshape

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Gabor Grothendieck
7:27:26 AM Subject: Re: [R] Merge data frames but with a twist. On Thu, Aug 27, 2009 at 9:55 AM, Stephen Tuckerbrown_...@yahoo.com wrote: You may want to use the reshape package for this task: library(reshape) recast(DF3,Show ~ Datetime, id.var=names(DF3),value=Measure)       Show 08/26/2009

Re: [R] Merge data frame and keep unmatched

2009-07-13 Thread Matthew Dowle
Or if you need it to be fast, try data.table. X[Y] is a join when X and Y are both data.tables. X[Y] is a left join, Y[X] is a right join. 'nomatch' controls the inner/outer join i.e. what happens for unmatched rows. This is much faster than merge(). Gabor Grothendieck

[R] Merge data frame and keep unmatched

2009-06-10 Thread Etienne B. Racine
Hi, With two data sets, one complete and another one partial, I would like to merge them and keep the unmatched lines. The problem is that merge() dosen't keep the unmatched lines. Is there another function that I could use to merge the data frames. Example: completedf -

Re: [R] Merge data frame and keep unmatched

2009-06-10 Thread Marc Schwartz
On Jun 10, 2009, at 8:56 AM, Etienne B. Racine wrote: Hi, With two data sets, one complete and another one partial, I would like to merge them and keep the unmatched lines. The problem is that merge() dosen't keep the unmatched lines. Is there another function that I could use to

Re: [R] Merge data frame and keep unmatched

2009-06-10 Thread Gabor Grothendieck
Try: merge(completedf, partdf, all.x = TRUE) or library(sqldf) # see http://sqldf.googlecode.com sqldf(select * from completedf left join partdf using(beta, alpha)) On Wed, Jun 10, 2009 at 9:56 AM, Etienne B. Racineetienn...@gmail.com wrote: Hi, With two data sets, one complete and

Re: [R] merge data frames with same column names of differe nt lengths and missing values

2009-03-08 Thread Dieter Menne
Steven Lubitz slubitz1 at yahoo.com writes: Thank you - this is very helpful. However I realized that with my real data sets (not the example I have here), I also have different numbers of columns in each data frame. rbind doesn't seem to like this. Here's a modified example: x -

Re: [R] merge data frames with same column names of differe nt lengths and missing values

2009-03-07 Thread Dieter Menne
Steven Lubitz slubitz1 at yahoo.com writes: x - data.frame(item1=c(NA,NA,3,4,5), item2=c(1,NA,NA,4,5), id=1:5) y - data.frame(item1=c(NA,2,NA,4,5,6), item2=c(NA,NA,3,4,5,NA), id=1:6) merge(x,y,by=c(id,item1,item2),all.x=T,all.y=T) #my rows are duplicated and the NA values are

Re: [R] merge data frames with same column names of different lengths and missing values

2009-03-07 Thread Domenico Vistocco
Steven Lubitz wrote: Hello, I'm switching over from SAS to R and am having trouble merging data frames. The data frames have several columns with the same name, and each has a different number of rows. Some of the values are missing from cells with the same column names in each data frame. I

Re: [R] merge data frames with same column names of different lengths and missing values

2009-03-07 Thread Jun Shen
Steve, I don't know if R has such a function to perform the task you were asking. I wrote one myself. Try the following to see if it works for you. The new function merge.new has one additional argument col.ID, which is the column number of ID column. To use your x, y as examples, type:

Re: [R] merge data frames with same column names of different lengths and missing values

2009-03-07 Thread Steven Lubitz
Subject: Re: [R] merge data frames with same column names of different lengths and missing values To: Phil Spector spec...@stat.berkeley.edu Date: Saturday, March 7, 2009, 5:01 PM Phil, Thank you - this is very helpful. However I realized that with my real data sets (not the example I have here

[R] merge data frames with same column names of different lengths and missing values

2009-03-06 Thread Steven Lubitz
Hello, I'm switching over from SAS to R and am having trouble merging data frames. The data frames have several columns with the same name, and each has a different number of rows. Some of the values are missing from cells with the same column names in each data frame. I had hoped that when I