I have data which as below
df <- data.frame("ID" = c(rep("AA",8), rep("BB",6)),
"A" = c(1:14),
"Flag" = c("N","Y",rep("N",2), rep("Y",3), "N", "N", "Y", "Y", "N", rep("Y", 2)))
For each ID I want to find the maximum length of a continuous Flag == "Y"
That is
AA 3
BB 2
Can't figure out how to go about