I have two dataframes. One that has a list of unique ID numbers (think customer names and demographic data) and another dataframe with a list of transaction data (think purchase data, $ amount, etc) where the same unique ID number is also a column.
I'd like to create a dummy variable using a nested ifelse statement that searches the transaction dataframe using the unique ID and then check if a second attribute matches between the two dataframes.
For example:
data.frame3$dummy_variable <- ifelse(data.frame1$id == data.frame2$id,
ifelse(data.frame1$attributeX == data.frame2$attritubeX, 1, 0)
,2)
However, data.frame1 and data.frame2 have different row lengths, so I get an error message: "longer object length is not a multiple of shorter object length".
These data.frames cannot be the same length. Is there another way to attack this?