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?
You can use rowSums to construct the condition in base R:
rowSums
df[rowSums(df > 10) >= 1, ]
with dplyr (0.7.0), now you can use filter_all like this:
dplyr
filter_all
library(dplyr) filter_all(df, any_vars(. > 10))
2.1m questions
2.1m answers
60 comments
57.0k users