I want to perform a left_join to add information from a different dataframe.
The data I'm using is somewhat fragmented, so I first created four columns to indicate whether the information matches one of the to-be-joined dataframe. This results in four TRUE-FALSE columns.
My question is if it would be possible to set the columns to be joined with, based on all the columns that are TRUE for that particular row? For example, if column A and column B are TRUE in the orignal dataframe, it should match with the columns A and B in the other dataframe.
I can imagine this is a bit of a complicated question, and I struggle a little to formulate everything correctly. That's why I can't provide a reproducible example, but I hope someone can still nudge me into the right direction.
Thanks, but I don't think this answers my question.
All rows in my df will have at least a TRUE in one ore more columns. The problem is that I need to match on the columns that show TRUE. Let's say the first row contains TRUE in column A and column B , the the left join should join by column A and column B. The next row only shows TRUE for column A , then do a left_join on just column A.
In my df I have four columns that could show TRUE/FALSE resulting in 13 different combinations.