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

Course Queries Syllabus Queries 3 years ago

9.17K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 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?

0 views
0 shares

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.

Similar Forum