Intermezzo: missing values (3)

Suppose we have a factor variable day:

daily
## # A tibble: 4 × 2
##   day   value
##   <fct> <dbl>
## 1 Tue       2
## 2 Thu       3
## 3 Fri       1
## 4 Mon       5
levels(daily$day)
## [1] "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"

Now you want a wide table including missing values for the absent factor levels.

Does this work?

daily |>
  pivot_wider(
    names_from = day,
    values_from = value
  )
## # A tibble: 1 × 4
##     Tue   Thu   Fri   Mon
##   <dbl> <dbl> <dbl> <dbl>
## 1     2     3     1     5

Obviously not.