I am having trouble which what I thought would be a simple issue.
I have the following vector (which is actually a column in a dataset)
example_data <- c(1, 2, 3, 4, 5, 6, 7, 8, 5, 9, 4, 5, 4, 5, 6, 5, 3, 3, 2, 4, 5, 6, 4, 5, 6, 6, 5)
I want to find the number of times that c(4, 5, 6)
occurs, exactly in that order. In the above example this would be 4 times.
I have attempted using %in%
and grepl()
but neither of those have proved successful. I have also tried collapsing the vector into one sequence and matching that way but no luck.
I just feel like I am missing something very obvious, so any help would be greatly appreciated.