Coworkers | Date |
---|---|
A | 2011-01-01 |
D | 2011-01-02 |
B;;D | 2011-01-03 |
E;;F | 2011-01-04 |
D | 2012-11-05 |
D;;G | 2012-11-06 |
A | 2012-11-09 |
Hello, I am trying to create a dummy variable based on text analysis (e.g., grepl
).
The unit of analysis is a project, and the two main variables are coworkers (text) and date.
I am curious if there is any way that I can create a dummy variable that indicates all projects done by a worker who collaborated with "B" (in this example, D) as 1. One more KEY condition I would like to add is... I would like to give the value of 1 only to projects that occurred AFTER B and D worked together. I mean, in this case, I want to mark the project in the second row, which is done by D, as 0 because it occurred before B and D met.
Can I create this type of variable using R commands? As I have millions of observations, I would not be able to do it manually. Alphabets in the table are texts.
Thank you!
PS. In the "Coworkers" column, coworkers are separated by ;;