[R] help with merging two dataframes function of "egrep"-like formulas

Bogdan Tanasa
Wed, 18 Jul 2018 23:03:12 -0000

Thanks a lot ! It looks that I am getting the same results with :

B %>% regex_left_join(A, by = c(z = 'z'))

On Wed, Jul 18, 2018 at 3:57 PM, Riley Finn <rileyfinn3 at gmail.com>
wrote:

> please may I ask for a piece of advise regarding merging two dataframes :
>> A <- data.frame(z=c("a*b", "c*d",
"d*e", "e*f"), t =c(1, 2, 3, 4))
>> B <- data.frame(z=c("a*b::x*y", "c",
"", "g*h"), t =c(1, 2, 3, 4))
>> function of the criteria :
>> if "the elements in the 1st column of A could be found among the
elements
>> of the 1st column of B" i.e.
>> for the example above, we shall combine in the results only the row
with
>> "a*b" of A with the row with "a*b::x*y" of B.
>
>
> This may be what you are looking for:
>
> library(fuzzyjoin)
>
> The inner join returns just the one row where the string matches.
> B %>%
>   regex_inner_join(A, by = c(z = 'z'))
>
> While the full join returns NA's where the string does not match.
> B %>%
>   regex_full_join(A, by = c(z = 'z'))
>
> On Wed, Jul 18, 2018 at 5:20 PM Bogdan Tanasa <tanasa at gmail.com>
wrote:
>
>> Dear all,
>>
>> please may I ask for a piece of advise regarding merging two dataframes
:
>>
>> A <- data.frame(z=c("a*b", "c*d",
"d*e", "e*f"), t =c(1, 2, 3, 4))
>>
>> B <- data.frame(z=c("a*b::x*y", "c",
"", "g*h"), t =c(1, 2, 3, 4))
>>
>> function of the criteria :
>>
>> if "the elements in the 1st column of A could be found among the
elements
>> of the 1st column of B" i.e.
>>
>> for the example above, we shall combine in the results only the row
with
>> "a*b" of A with the row with "a*b::x*y" of B.
>>
>> thank you,
>>
>> bogdan
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/
>> posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

	[[alternative HTML version deleted]]