I have two dataframes (df1, df2). I would like to combine them such that if a gene is present in df1 for a specific sample ID, I would like it to be allocated "1" (present") in the appropriate matching gene column and sample ID row in df2. If the gene is not present in df1, it would autopopulate df2 with a "0" (absent), as seen in the result dataframe below. Your assistance on this would be much appreciated. Thank you in advance.
df1
+-----------+-----+
| Gene name | ID |
+-----------+-----+
| A | 100 |
| A | 105 |
| B | 100 |
| B | 101 |
| B | 103 |
| C | 105 |
+-----------+-----+
df2
+-----+---+---+---+---+
| ID | A | B | C | D |
+-----+---+---+---+---+
| 100 | | | | |
| 101 | | | | |
| 102 | | | | |
| 103 | | | | |
| 104 | | | | |
| 105 | | | | |
| 106 | | | | |
+-----+---+---+---+---+
result
+-----+---+---+---+---+
| ID | A | B | C | D |
+-----+---+---+---+---+
| 100 | 1 | 1 | 0 | 0 |
| 101 | 0 | 1 | 0 | 0 |
| 102 | 0 | 0 | 0 | 0 |
| 103 | 0 | 1 | 0 | 0 |
| 104 | 0 | 0 | 0 | 0 |
| 105 | 0 | 0 | 1 | 0 |
| 106 | 0 | 0 | 0 | 0 |
+-----+---+---+---+---+