Nitro Nitro - 23 days ago 7
R Question

R keep rows with at least one column greater than value

Say I have a data frame with a few hundred rows and a few hundred columns. How would I keep rows that have at least one value greater than 10?

Answer Source

You can use rowSums to construct the condition in base R:

df[rowSums(df > 10) >= 1, ]

with dplyr (0.7.0), now you can use filter_all like this:

library(dplyr)
filter_all(df, any_vars(. > 10))