【发布时间】:2021-05-07 15:25:54
【问题描述】:
我有一个数据框,我想删除所选列中存在 Inf 值的行。我正在寻找使用 tidyverse 的解决方案,因为我想将它包含到我的 tidyverse 管道中。
例子:
df <- data.frame(a = c(1, 2, 3, NA), b = c(5, Inf, 8, 8), c = c(9, 10, Inf, 11), d = c('a', 'b', 'c', 'd'))
我想删除c 列中具有 Inf 值的行。结果是:
df2 <- data.frame(a = c(1, 2, NA), b = c(5, Inf, 8), c = c(9, 10, 11), d = c('a', 'b', 'd'))
我希望有一个类似于drop_inf() 的函数,类似于drop_na()。
编辑:列名作为变量传递。
【问题讨论】:
标签: r dataframe dplyr tidyverse infinity