I have the following table and would like to have a new column in R for every unique ID
MeetingID <- c("01", "02","03","02","04","03")
Attendee <- c("Alex","Bob","Tim","Xavier","Ana","Bob")
AttendedMonth <- c("Jan","Apr","Feb","Apri","Feb","Feb")
df <- data.frame(MeetingID, Attendee,AttendedMonth)
| MeetingID | Attendeee | AttendedMonth |
|---|---|---|
| 01 | Alex | Jan |
| 02 | Bob | Apr |
| 03 | Tim | Feb |
| 02 | Xavier | Apr |
| 04 | Ana | Feb |
| 03 | Bob | Feb |
I intend to create a dataframe similar to a matrix where for each MeetingID, i want to label (0) if the the attendee did not attend the meeting and (1) if the attendee attended the meeting
| Attendee | 01 | 02 | 03 | 04 |
|---|---|---|---|---|
| Alex | 1 | 0 | 0 | 0 |
| Bob | 0 | 1 | 1 | 0 |
| Tim | 0 | 0 | 1 | 0 |
| Xavier | 0 | 1 | 0 | 0 |
| Ana | 0 | 0 | 0 | 1 |