Skip to main content

actionDateTime

actionDateTime      text         response                    postTime

2019-01-01 12:00    Hi           N/A                         2019-01-01 12:00
2019-01-01 12:01    Hi           Hello!                      2019-01-01 12:00
2019-01-01 12:02    Hi           How can I help?             2019-01-01 12:00
.
.
.
2019-01-02 12:00    Hi there      N/A                        2019-01-01 12:00
2019-01-02 12:01    Hi there      Morning                    2019-01-01 12:00
2019-01-02 12:02    Hi there      How can I help?            2019-01-01 12:00
    
df %>%
group_by(text, postTime) %>%
mutate(convID = row_number()) %>%
ungroup()
    
text         response                    postTime           convID

Hi           N/A                         2019-01-01 12:00   1
Hi           Hello!                      2019-01-01 12:00   2
Hi           How can I help?             2019-01-01 12:00   3
.
.
.
Hi there      N/A                        2019-01-01 12:00   1
Hi there      Morning                    2019-01-01 12:00   2
Hi there      How can I help?            2019-01-01 12:00   3

What I want:
    
library(dplyr)
df %>%
  mutate(convID = group_indices(., text, postTime))