Learn R Programming

BoardGames (version 1.0.0)

detect_seq: Detects if a certain sequence is present in a matrix.

Description

This function allows for the detection of a particular sequence in a matrix.

Usage

detect_seq(data, sequence, reps, diag = TRUE)

Arguments

data
A matrix.
sequence
The desired sequence to search for.
reps
Number of repetitions of the sequence.
diag
Do you want to search diagonals? Defaults to TRUE.

Examples

Run this code
M = matrix(sample(c(1,2),25,replace=TRUE),5,5)
detect_seq(data = M, sequence = "2", reps = 5)
#or equivalently
detect_seq(data = M, sequence = "22222", reps = 1)

Run the code above in your browser using DataLab