Re: [R] Merge two data frames on date field

2014-02-07 Thread arun
Hi,You haven't provided any example dataset.  set.seed(42)  dat1 <- data.frame(dates=seq(as.POSIXct("2009-01-01 00:00:00",format="%Y-%m-%d %H:%M:%S"),by= '12 hour', length=12),Field1=rnorm(12),Field2=LETTERS[1:12]) set.seed(395)  dat2 <- data.frame(dates=seq(as.POSIXct("2009-01-01 00:00:00",for

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-04 Thread francesca casalino
Sorry---I thought it worked but I think I am actually definitely doing something wrong... The problem might be that there are NA's and there are also duplicated values...My fault. I can't figure out what is going wrong... I'll be more thorough and modify the two df to mirror more what I have to ex

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-04 Thread francesca casalino
Yes, your code did exactly what I needed. Thank you!! -f [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-gu

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread Sarah Goslee
Hi, On Mon, Oct 3, 2011 at 1:54 PM, francy wrote: > Hi, > > I am trying to find a function to match two data frames of different lengths > for one field only. > So, for example, > df1 is: > > Name Position location > francesca A 75 > cristina B 36 > > And df2 is: > > location Country > 75 UK > 5

Re: [R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread William Dunlap
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of francy > Sent: Monday, October 03, 2011 10:55 AM > To: r-help@r-project.org > Subject: [R] Merge two data frames and find common values and non-matching > values > > Hi, > > I am tryin

[R] Merge two data frames and find common values and non-matching values

2011-10-03 Thread francy
Hi, I am trying to find a function to match two data frames of different lengths for one field only. So, for example, df1 is: Name Position location francesca A 75 cristina B 36 And df2 is: location Country 75 UK 56 Austria And I would like to match on "Location" and the output to be something

[R] merge two data frames

2010-08-04 Thread Amos Folarin
Hi Arnaud, It is slightly confusing what you are asking but if you just want a dataframe with the two zz$"PL" and av$"PL" columns concatenated then merge is not what you are after. Try something like this. t <- rbind(data.frame(PL=zz$PL), data.frame(PL=av$PL)) > t PL 1 307

Re: [R] merge two data frames

2010-08-04 Thread arnaud gaboury
TY Petr, it works. I will then replace NA by 0. 2010/8/4 Petr PIKAL : > Hi > > you tried OK > > result <- merge(zz, av, by="DESCRIPTION", all=TRUE) > > and as you did not specify what to do when one value is NA  here is one > possible solution > > rowSums(cbind(result$PL.x, result$PL.y), na.rm=T)

[R] merge two data frames

2010-08-04 Thread arnaud gaboury
Dear list, here are my two data frames: av <- structure(list(DESCRIPTION = c("COFFEE C Sep/10", "COPPER Sep/10", "CORN Dec/10", "CRUDE OIL miNY Sep/10", "GOLD Aug/10", "HENRY HUB NATURAL GAS Sep/10", "PALLADIUM Sep/10", "SILVER Sep/10", "SOYBEANS Nov/10", "SPCL HIGH GRADE ZINC USD", "SUGAR NO.11

Re: [R] merge two data frames

2010-05-11 Thread arnaud Gaboury
Got it! First, here is the correct line : >y=merge(value,allcon,all.y=T) Then, I got NA because of some white space (blancs) in names of elements of my data frame "VALUE".It came from the .csv file from where I obtained the VALUE df. TY Excel again! In fact, as a general advice, I would SYSTEMAT

[R] merge two data frames

2010-05-11 Thread arnaud Gaboury
Dear group, I have these 2 following data frame: allcon <- structure(list(DESCRIPTION = structure(1:17, .Label = c("COFFEE C Jul/10", "COPPER May/10", "CORN Jul/10", "CORN May/10", "COTTON NO.2 Jul/10", "CRUDE OIL miNY May/10", "GOLD Jun/10", "HENRY HUB NATURAL GAS May/10", "ROBUSTA COFFEE (10