Reputation: 64074
I have a data frame that looks like this
df <- data.frame(cbind(1:10, sample(c(1:5), 10, replace=TRUE)))
# in real case the columns could be more than two
# and the column name could be anything.
What I want to do is to remove all rows where the value of all its columns is smaller than 5. What's the way to do it?
Upvotes: 0
Views: 2354
Reputation: 263481
First of all ...please stop using cbind
to create data.frames. You will be sorry if you continue. R will punish you.
df[ !rowSums(df <5) == length(df), ]
(The length() function returns the number of columns in a dataframe.)
Upvotes: 1