类似于subset或filter功能中,对数据框中所有列进行筛选,怎么选择所有列啊?就是想对数据框里的所有数值进行筛选,保留±0.8以外的数据,怎么写啊,我总感觉一个语句就可以的,百度了一天,不会啊。
#我的错误代码:
data6 <- data1 %>% filter(across(everything(), ~.x >= 0.8 & ~.x <= -0.8))
#报错:
Error in `filter()`:
i In argument: `across(everything(), ~.x >= 0.8 & ~.x <= -0.8)`.
Caused by error in `across()`:
! Can't compute column `A2ML1`.
Caused by error in `.x >= 0.8 & (~ .x <= -0.8)`:
! operations are possible only for numeric, logical or complex types
Run `rlang::last_trace()` to see where the error occurred.
#我的错误瞎写的代码
data5 <- subset.data.frame(data1, abs(data1) >= 0.8)
#结果不对。。。