Assuming I have a data frame like
term cnt
apple 10
apples 5
a apple on 3
blue pears 3
pears 1
How can I filter out all partial found rows in this column, for example. getting as a result
term cnt
apple 10
pears 1
without specifying which terms I want to filter (apple | pears), but using the self-reference method (that is, it checks each expression for the entire column and removes terms that are a partial match). The number of tokens is not limited, and the consistency of the lines (for example, "kapples" will not match the "apple"). This will result in an inverted generic version
based on dplyr,d[grep("^apple$|^pears$", d$term), ]
In addition, it would be interesting to use this deaeration to get the total, for example
term cnt
apple 18
pears 4
I could not get it to work with contains () or grep ().
thank