r - filter_all 给了我相同的未过滤数据框
问题描述
我试图仅查找当前诊断并过滤到任何大于 2 的值。我认为我不一定会以正确的方式进行此操作,但这是我现在拥有的代码行。通过我所写的内容,我刚刚返回了一个名为 FU 的数据帧,它与 FU 完全相同。不完全确定我的问题从哪里来。
解决方案
我们需要filter_at
而不是filter_all
library(dplyr)
fuKSADS_1%>%
select(ends_with('Current')) %>%
filter_all(any_vars( . > 2))
或者另一种选择是c_across
fuKSADS_1 %>%
select(ends_with('Current')) %>%
rowwise %>%
filter(any(c_across(everything()) > 2)) %>%
ungroup
中base R
,我们可以使用Reduce
i1 <- endsWith(names(fuKSADS_1), 'Current')
subset(fuKSADS_1[i1], Reduce(`|`, lapply(fuKSADS_1[i1], `>`, 2)))
推荐阅读
- angular - 如何验证动态添加的表单字段的重复项
- javascript - 检查nuxt中的空查询参数
- flutter - 我们如何在 Flutter 中的 TextForm 上添加上标或下标字符串?
- python - 加载嵌套到 Dataframe Pandas 的 Json
- python - Tensorflow:ImportError:DLL加载失败:找不到模块
- php - 第 3 行实体中 DomDocument 文档为空的原因
- javascript - 如何使用 nextjs 和 react hook 在我的页面页脚中显示网络生命体征指标?
- javascript - 如何使用两个下拉菜单抓取地图?
- xamarin - 适用于 Xamarin 的 OneSignal SDK:HandleNotificationReceived 未在华为设备上触发,但 HandleNotificationOpened 它是
- javascript - 使用 document.execCommand() 时如何防止触发 onInput 事件?