partial matching of strings in different two datasets to obtain a match with higher frequency

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


I have strings in two datasets and i would like to do a partial match. Here is the code that I have written

 df1 <- data.frame(A=c(.87,.11,.44,.45), B=c("I have a beard", "I slept for two hours", "I have had two courses","this is not true"))

 df2 <- data.frame(X=c(127,10,433,344,890,4),Y=c("have","beard","syllabus","true","three","maths"))

I want to do a pmatch and I am expecting output as follows

  A     B                            X      Y
.87   I have a beard               127      have
.11   I slept for two hours        NA       NA
.44   I have had two courses       127      have
.45   this is not true             344      true

I would like to a partial match with a left join on df1. I want to get the higher of the two matches(for example in "I have a beard" string "have" match has 127 and "beard" has 10 and i want to get the higher match. Any suggestions?

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.