I would like to delete rows of data in a dataframe if the values in a column (in this case a participant identification number) fall within a certain range e.g. 61701 to 61721 & 61901 to 61929.
I know how to subset data based on a threshold e.g.:
datasetnew = dataset[dataset$X<=100, ]
But not sure how to subset and remove the rows using a range of numbers. Not sure subset is what I need.
You should be able to exclude those ranges by including everything less than, greater than, and in between them. Something like:
Or using
subset
:Or a more straight forward implementation will be just negate these rows using
!
Or
For a big data set you can use
data.table
s%between%
functionUsing dplyr package: