I have this dataframe:
df <- structure(list(x = c(1, 5, 6, 7, 8), y = c("a", "e", "f", "g",
"h")), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-5L))
x y
<dbl> <chr>
1 1 a
2 5 e
3 6 f
4 7 g
5 8 h
With complete
from tidyr
package:
I can do:
df %>%
complete(x = full_seq(min(x):max(x), 1))
x y
<dbl> <chr>
1 1 a
2 2 NA
3 3 NA
4 4 NA
5 5 e
6 6 f
7 7 g
8 8 h
Now I would like to do the same with the y
column:
df %>%
complete(y = full_seq(min(y):max(y), 1))
This obviously will not work.
How can I use complete
from tidyr
package for alphabetical order?