【发布时间】:2019-10-23 22:58:57
【问题描述】:
library(tidyverse)
iris %>% as_tibble() %>% select(everything())
#> # A tibble: 150 x 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> 7 4.6 3.4 1.4 0.3 setosa
#> 8 5 3.4 1.5 0.2 setosa
#> 9 4.4 2.9 1.4 0.2 setosa
#> 10 4.9 3.1 1.5 0.1 setosa
#> # ... with 140 more rows
假设我想选择iris 数据框中除Species 之外的所有内容。在使用tidyselect::everything() 时如何列出这一异常?
我的实际管道在下面,当
... %>%
group_by(`ID`) %>%
fill(everything, .direction = "updown") %>%
... %>%
我收到以下错误:
错误:无法修改列
ID,因为它是一个分组变量
【问题讨论】:
-
你有什么理由不做
iris %>% as_tibble() %>% select(-Species)? -
另外,如果您尝试删除分组变量,您可能需要在运行
select命令之前ungroup()。 -
@Mako212 我不得不重新创建问题以表明我的意图。感谢这些线索。其他问题在这里-> stackoverflow.com/questions/58542413/…
标签: r dplyr tidyr tidyselect