I am looking for an easy way to filter rows from data.frame based on a list of number sequences.
Here is an example:
My original data frame:
data <- data.frame(x=c(0,1,2,0,1,2,3,4,5,12,2,0,10,11,12,13),y="other_data")
My list:
list1 <- list(1:5,10:13)
My goal is to save only rows from "data" that contain exactly the same numerical sequence "list1" as in the column "x" of "data". Thus, the output data.frame should be:
finaldata <- data.frame(x=c(1:5,10:13),y="other_data")
Any ideas for this?
list r filtering
jeff6868
source share