Unable to use tidyselect `everything()` in combination with `group_by()` and `fill()`

陌路散爱 提交于 2019-12-06 08:03:42

You can do:

df %>%
 group_by(x1) %>%
 fill(-x1, .direction = "updown")

  x1       x2    x3
  <chr> <dbl> <dbl>
1 A         8     3
2 A         8     6
3 A         8     5
4 B         5     9
5 B         5     1
6 B         5     9

This behavior is documented in the documentation of tidyr (also look at the comment from @Gregor):

You can supply bare variable names, select all variables between x and z with x:z, exclude y with -y.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!