I have the following data frame:

```
library(tidyverse)

df <- data.frame(
  vars = rep(letters[1:2], 3),
  value = c(10,12,15,19,22,23),
  phase = rep(factor(c("pre","post1","post2"), levels = c("pre","post1","post2")),2)
) %>% 
  arrange(vars,phase)

```

And I would like to calculate the **difference** in `value` of the following:

* `post1 - pre`
* `post2 - post1`
* `post2 - pre`

for each `var` (i.e., `a` and `b`).

What would be the most efficient way of achieving this using `tidyverse`?

**Expected outcome:**

```
 vars         x     diffs
    a   post1 - pre    12
    a post2 - post1    -7
    a   post2 - pre     5
    b   post1 - pre    -7
    b post2 - post1    11
    b   post2 - pre     4

```