yes thanks, that's correct!
here a slight variation inspired by your solution: a cartesian product
restricted to non duplicated records to get the logical vector i to be
used in the next natural join
i<-!duplicated(merge(df1$id,df1$item, by=NULL))
merge(df1[i,],df2)
thanks
Il 08/05/2014 18:
Hi,
May be:
indx <- !duplicated(as.character(interaction(df1[,-3])))
merge(df1[indx,],df2)
A.K.
On Thursday, May 8, 2014 12:34 PM, Massimo Bressan
wrote:
yes, thank you for all your replies, they worked out correctly indeed...
...but because of my fault, by then working on my real data I ful
yes, thank you for all your replies, they worked out correctly indeed...
...but because of my fault, by then working on my real data I fully
realised that I should have mentioned something that is changing (quite
a lot, in fact) the terms of the problem...
please would you consider the follow
Hi,
May be this helps:
merge(unique(df1),df2)
A.K.
On Thursday, May 8, 2014 5:46 AM, Massimo Bressan
wrote:
given this "bare bone" example:
df1 <- data.frame(id=rep(1:3,each=2), item=c(rep("A",2), rep("B",2),
rep("C",2)))
df2 <- data.frame(id=c(1,2,3), who=c("tizio","caio","sempronio"))
Hello,
There are some alternatives without using sqldf or another package.
1.
tmp2 <- aggregate(item ~ id, data = df1, FUN = unique)
Then merge() like you've done.
2.
tmp3 <- merge(df1, df2)
tmp3[!duplicated(tmp3), ]
Hope this helps,
Rui Barradas
Em 08-05-2014 10:44, Massimo Bressan escr
given this "bare bone" example:
df1 <- data.frame(id=rep(1:3,each=2), item=c(rep("A",2), rep("B",2),
rep("C",2)))
df2 <- data.frame(id=c(1,2,3), who=c("tizio","caio","sempronio"))
I need to group the first dataframe "df1" by "id" and then merge with
the second dataframe "df2" (again by "id")
6 matches
Mail list logo