I have the following data.frame “A” in R:
ID | Interaction.Type | Target.ID | Student | Created.At |
---|---|---|---|---|
1 | email_sent | 368932 | Isabel Gauss | 10/20/2021 0:02 |
1 | email_sent | 370153 | Isabel Gauss | 11/2/2021 0:04 |
1 | Open_sent | 375012 | Isabel Gauss | 12/6/2021 22:15 |
1 | email_sent | 382353 | Isabel Gauss | 2/3/2022 0:06 |
50 | email_sent | 368932 | Jen Gonzalez | 10/20/2021 0:02 |
50 | email_sent | 370153 | Jen Gonzalez | 11/2/2021 0:04 |
50 | email_sent | 375012 | Jen Gonzalez | 12/6/2021 22:15 |
10 | email_sent | 354609 | Isabel Goodwin | 9/23/2021 21:09 |
10 | email_sent | 368089 | Isabel Goodwin | 10/20/2021 0:02 |
10 | email_sent | 375017 | Isabel Goodwin | 12/5/2021 21:05 |
10 | Open_sent | 383095 | Isabel Goodwin | 2/8/2022 1:05 |
200 | email_sent | 343546 | Jason Bin | 10/9/2022 21:05 |
200 | email_sent | 343543 | Jason Bin | 2/8/2021 1:05 |
550 | email_sent | 546354 | Brad pit | 05/29/2023 0:02 |
550 | email_sent | 344546 | Brad pit | 10/20/2021 0:02 |
550 | email_sent | 343434 | Brad pit | 08/15/2022 0:02 |
And the following integer table “B” in R
ID |
---|
1 |
125 |
200 |
550 |
870 |
I need to group data.frame "A" first to come up with the below:
ID | Interaction.Type | Student | Min_Created.At |
---|---|---|---|
1 | email_sent | Isabel Gauss | 10/20/2021 0:02 |
50 | email_sent | Jen Gonzalez | 10/20/2021 0:02 |
11 | email_sent | Isabel Goodwin | 9/23/2021 21:09 |
200 | email_sent | Jason Bin | 2/8/2021 1:05 |
550 | email_sent | Brad Pit | 10/20/2021 0:02 |
And then filter the above output using the above ID table "B" to come up with the below:
ID | Interaction.Type | Student | Min_Created.At |
---|---|---|---|
1 | email_sent | Isabel Gauss | 10/20/2021 0:02 |
125 | Null | Null | Null |
200 | email_sent | Jason Bin | 2/8/2021 1:05 |
550 | email_sent | Brad Pit | 10/20/2021 0:02 |
870 | Null | Null | Null |
The following is not working:
Output_1 <- data.frame(A$ID, A$Interaction.Type == "email_sent", A$Student, Min(A$Created.At), group_by(ID))