On 24-02-2012, at 08:30, Apoorva Gupta wrote: > Dear R users, > > I have a data.frame as follows > > a b c d e > [1,] 1 1 1 0 0 > [2,] 1 1 0 0 0 > [3,] 1 1 0 0 0 > [4,] 0 1 1 1 1 > [5,] 0 1 1 1 1 > [6,] 1 1 1 1 1 > [7,] 1 1 1 0 1 > [8,] 1 1 1 0 1 > [9,] 1 1 1 0 0 > [10,] 1 1 1 0 0 > > Within these 4 vectors, I want to choose those vectors for which I > have the pattern (0,0,1,1,1,1) occuring anywhere in the vector. > This means I want vectors a,c,e and not b and d. >
See this thread "[R] matching a sequence in a vector?" : http://tolstoy.newcastle.edu.au/R/e17/help/12/02/4201.html Berend ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.