I have two dataframes, and want to add values from the 2nd one to the 1st one according to string values, but use partial string matching if there is a space
df1:
cat
small dog
apple
df2:
cat 24
small 5
dog 400
apple 83
pear 55
I normally use "left_join" from tidyverse, which would be
df3 <- left_join(df1, df2, by="column_name")
df3:
cat 24
small dog NA
apple 83
but this means that "small dog" has a missing value. What I want to do this time is find the value for either "small" or "dog", and input whichever is bigger. I'm not able to find a function that will tell R to look separately before or after the space though