Dear all,

I have a dataset of this type:

```
subject start_time word label
s1 1.00 go g
s1 1.00 go g
s1 1.20 eat t
s1 1.20 eat t
s2 1.00 go g
s2 1.00 go g
s2 1.20 eat t
s2 1.20 eat t
s3 1.00 go g
s3 1.00 go g
s3 1.20 eat t
s3 1.20 eat t
```

and I would like to create an `id`

column based `subject`

and `start_time`

. The output I am looking for is similar to this:

```
subject start_time word id
s1 1.00 go 1
s1 1.00 go 1
s1 1.20 eat 2
s1 1.20 eat 2
s2 1.00 go 1
s2 1.00 go 1
s2 1.20 eat 2
s2 1.20 eat 2
s3 1.00 go 1
s3 1.00 go 1
s3 1.20 eat 2
s3 1.20 eat 2
```

Note that for each duplicate `start_time`

within `subject`

I want to assign one fixed number/value. I tried to use

```
dat %>%
group_by(subject, start_time) %>%
mutate(
id= row_number())
```

But this did not work.

I also tried using this:

```
dat %>%
group_by(subject, start_time) %>%
mutate(id= cur_group_id())
```

it worked but the number continues progressively for each subject. for `s1`

it gives 1 1 2 2, for `s2`

it gives 3 3 4 4, for `s3`

it gives 5 5 6 6, and so on, which is not the thing I am looking for.

I would appreciate your help.

Thanks in advance!