I have a dataframe consisting of online reviews. I have assigned topics (topic 1-5; and 0 meaning no topic is assigned) and labels (positive or negative) in each instance. I want to create a dummy variable for each topic and label. This is what my data looks like...
reviewId | topic | label |
---|---|---|
01 | 2 | negative |
02 | 2 | positive |
03 | 0 | negative |
04 | 5 | negative |
05 | 1 | positive |
What should I do to make my data look like this? (1 meaning assigned, 0 meaning not assigned)
reviewId | topic | label | T1pos | T1neg | T2pos | T2neg | T3pos | T3neg | T4pos | T4neg | T5pos | T5neg |
---|---|---|---|---|---|---|---|---|---|---|---|---|
01 | 2 | negative | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
02 | 2 | positive | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
03 | 0 | negative | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
04 | 5 | negative | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
05 | 1 | positive | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |