Skip to main content
Maverick Noah
High hopes get Higher vibes
Asked a question 6 months ago

how to create subset in r?

Where am I?

In answerQA you can ask and answer questions and share your experience with others!

Charles Eli
I Don't want a perfect life. I want a happy life.

To combine multiple conditions to subset a data frame using ‘OR’, use the following:

my.data8.frame <- subset(data , V1 > 2 | V2 < 4)

You can also use the filter function from the dplyr package as follows:

library(dplyr) 

filter(data, V1 > 2 | V2 < 4)