[R] Ids with matching number combinations?

2022-10-07 Thread Marine Andersson
Hi, If I have two datasets like this: df=data.frame("id"=rep(1:10,10, each=10), "item1"=sample(1:20, 100, replace=T) df2=data.frame("a"=c(8, 8,10,9, 5, 1,2,1), "b"=c(16,18,11, 19,18, 11,17,12)) How do I find out which ids in the df dataset that has a match for both the numbers occuring in the sa

Re: [R] Ids with matching number combinations?

2022-10-07 Thread PIKAL Petr
Hallo Marine Could you please make your example more reproducible by using set.seed (and maybe smaller)? If I understand correctly, you want to know if let say row 1 items from df2 (8,16) are both in item column of specific id? If I am correct in guessing, I cannot find another solution than spl

Re: [R] Ids with matching number combinations?

2022-10-07 Thread Ebert,Timothy Aaron
Would an inner_join work? If not, please describe why so that we can improve our answer. This answer requires the dplyr package. https://statisticsglobe.com/r-dplyr-join-inner-left-right-full-semi-anti Regards, Tim -Original Message- From: R-help On Behalf Of PIKAL Petr Sent: Friday, Oc

Re: [R] Ids with matching number combinations?

2022-10-07 Thread Jeff Newmiller
The merge function doesn't require a package. But inner_join may be faster than merge. On October 7, 2022 8:16:11 AM PDT, "Ebert,Timothy Aaron" wrote: >Would an inner_join work? If not, please describe why so that we can improve >our answer. This answer requires the dplyr package. >https://stat

Re: [R] Ids with matching number combinations?

2022-10-07 Thread Bert Gunter
Well, for a start, you might give us a reproducible example that actually runs -- yours doesn't. Did you check? You seem to b.e missing a final ")"(Also, you do not need to quote the column names in data.frame(), though it works fine also if you do). Also note that in df, your id column has length