I have tested participants at three points in time. I have the dates at which they were tested. I want to make a column which levels are first, second, and third. Each participant has three dates, so they are all different per participant. The data looks like this:
structure(list(id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L), time_tested = c("2022-02-05", "2022-02-05", "2022-02-05",
"2022-02-08", "2022-02-08", "2022-02-08", "2022-02-11", "2022-02-11",
"2022-02-11", "2022-02-08", "2022-02-08", "2022-02-08", "2022-02-10",
"2022-02-10", "2022-02-10", "2022-02-13", "2022-02-13", "2022-02-13",
"2022-02-05", "2022-02-05", "2022-02-05", "2022-02-08", "2022-02-08",
"2022-02-08", "2022-02-11", "2022-02-11", "2022-02-11")), class = "data.frame", row.names = c(NA,
-27L))
and this is the result I want:
structure(list(id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L), time_tested = c("2022-02-05", "2022-02-05", "2022-02-05",
"2022-02-08", "2022-02-08", "2022-02-08", "2022-02-11", "2022-02-11",
"2022-02-11", "2022-02-08", "2022-02-08", "2022-02-08", "2022-02-10",
"2022-02-10", "2022-02-10", "2022-02-13", "2022-02-13", "2022-02-13",
"2022-02-05", "2022-02-05", "2022-02-05", "2022-02-08", "2022-02-08",
"2022-02-08", "2022-02-11", "2022-02-11", "2022-02-11"), period = c("first",
"first", "first", "second", "second", "second", "third", "third",
"third", "first", "first", "first", "second", "second", "second",
"third", "third", "third", "first", "first", "first", "second",
"second", "second", "third", "third", "third")), class = "data.frame", row.names = c(NA,
-27L))
Thank you!