streaks: streaks

Description Usage Arguments Examples

View source: R/streaks.R

Description

Function to find streaks in a vector, typically winning or losing streaks. Slight modification of function by Jim Albert at https://baseballwithr.wordpress.com/2014/07/07/team-streaks-part-i-2/

Usage

1
streaks(myvector, streakitem = "W", nonstreakitem = "L")

Arguments

myvector

a vector of characters or numbers such as 0 and 1.

streakitem

a character or number that stands for the item you're seeking a streak for, such as "W" or 1.

nonstreakitem

a character or number that stands for the item that usually interrupts the streak, such as "L" when seeking "W" streaks. There can be other streak-interrupting items not identified, such as "T" for ties.

Examples

1
2
seasonrecord <- c("Win", "Win", "Win", "Loss", "Loss", "Win", "Tie", "Win", "Win", "Win", "Win", "Win", "Win", "Win", "Loss", "Win")
streaks(seasonrecord, "Win", "Loss")

smach/rmiscutils documentation built on Dec. 15, 2021, 1:49 a.m.