Match two lists in R, one with partial rows and the other with a full row, return the whole row if they match. Return only unique matches (once).
So let's say I have a CSV file, and each line has a long line (long list). Then I cut the line with substr, and then I delete any duplicate lines using unique ones. Then I want to compare a long list of df12 lines with a unique short list of df14 , and if there are unique matches in a partial line search ( df14 vs df12 ) then return the whole line from df12 .
This is df12 (long list of lines)
[1] I like stackoverflow very much today [2] I like stackoverflow much today [3] I dont like stackoverflow very much today [4] I dont like you! [5] What? df13<-substr(df12, start=0, stop=30)
This is df13 (shortened strings are not unique)
[1] I like stacko [2] I like stacko [3] I dont like s [4] I dont like y [5] What? df14<-unique(df13)
This is df14 (abbreviated lines are unique lines after applying a unique method)
[1] I like stacko [2] I dont like s [3] I dont like y [4] What?
This is the result I want at the end
[1] I like stackoverflow very much today [2] I dont like stackoverflow very much today [3] I dont like you! [4] What?
source share