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:
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))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments