I have some pre-post data (in R) for which some individuals only have a value for time 1, like episode "2" here:
episode <- c('1','1','2','3','3')
score <- c('44','12','37','40','9')
df <- data.frame(episode,score)
For all the records where there is only "pre" data (1 score per episode), I would like to use R (dplyr preferred) to copy that record and then indicate for all records which is the pre and which is the post. So the final should look something like:
| episode | score | time |
|---|---|---|
| 1 | 44 | 1 |
| 1 | 12 | 2 |
| 2 | 37 | 1 |
| 2 | 37 | 2 |
| 3 | 40 | 1 |
| 3 | 9 | 2 |
Thanks!