i have a data table as this example below:
| col1 | col2 |
|---|---|
| a,b,c,d | a,c,d |
| r,h,g | r |
so each column of this table contain a list. I wanted to create 2 other list in 2 different columns, each one represent the intersect or union of col1 and 2:
the output that I want is this one :
| col1 | col2 | inter | union |
|---|---|---|---|
| a,b,c | a,c,d,k | a,c | a,b,c,d,k |
| r,h,g | r | r | r,h,g |
I tried this command but it gives me an error:
data$inter = intersect(data$col1, data$col2)
the error is :
Error in set(x, j = name, value = value) :
Supplied 4 items to be assigned to 748 items of column 'intersect'. If you wish to 'recycle' the RHS please use rep() to make this intent clear to readers of your code
FYI: its not the real data, its just a simplify example, the error that I am showing is for the real data
Thank you in advance