- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个主要数据框,其中有两组我想删除的列名称:
df1 <- structure(list(a = c(1, 2), b = c(3, 4), c = c(5, 6), d = c(7,
8), e = c(9, 10)), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"))
df2 <- structure(list(a = c(1, 2), b = c(3, 4), c = c(5, 6)), row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"))
我想删除以下列表中的任何列名称:“c”、“d”、“e”。
当我使用 one_of()
select helper 执行此操作时,我收到警告:
> tibble(a = c(1,2), b = c(3,4), c = c(5,6)) %>% select(-one_of("c","d","e"))
# A tibble: 2 x 2
a b
<dbl> <dbl>
1 1 3
2 2 4
Warning message:
Unknown columns: `d`, `e`
较大的警告为 0。
请告知如何在不发出警告的情况下按列名称组进行过滤?如果我想忽略的列存在于 one_of()
中,则忽略它,否则保留它。
最佳答案
我希望我的回答能够解决您的问题,我使用select_if函数而不是使用select的辅助函数。如果您想了解有关 select_if 的更多信息,请在 RStudio 控制台中输入 ?select_if
tibble(a = c(1,2), b = c(3,4), c = c(5,6)) %>% select_if(colnames(.) %in% c("a","c","d","e"))
谢谢!
关于r - dplyr select one_of() 帮助程序返回警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54983094/
我正在使用 devtools::check() 运行 R CMD 检查对于我正在编写的包,我在检查中遇到以下注意事项: * checking R code for possible problems
为什么是 dplyr::one_of()叫那个?所有其他 select_helpers名字对我来说很有意义,所以我想知道 one_of() 是否有一个方面我不明白。 我对 one_of() 的理解是它
我有两个主要数据框,其中有两组我想删除的列名称: df1 tibble(a = c(1,2), b = c(3,4), c = c(5,6)) %>% select(-one_of("c","d",
我有两个主要数据框,其中有两组我想删除的列名称: df1 tibble(a = c(1,2), b = c(3,4), c = c(5,6)) %>% select(-one_of("c","d",
我有一个名为 test 的小数据集,我想在其中对向量 cm 中定义的列执行一些变异操作。 安装和加载一些包 require(devtools) devtools::install_github("
我的数据如下所示: library(dplyr) set.seed(123) df % mutate_if(is.numeric, funs(new = . - ref)) 如果我只想对列的子集
我是一名优秀的程序员,十分优秀!