I have data in which the rows are ordered in chrono order of all shots taken in a game and the column "fg_result" is given a 1 for a made shot and a 0 for missed shot. I want to mutate a column in dplyr that returns the number of shots made in a row. I feel like a lag or lead function would be needed but am not sure. Here's a short piece of the df I'm working with. You'll notice only one miss (0) and the rest 1s. Ideally, the correct result for what I want is a new col (made_in_row) to equal 1, 2, 0, 1, 2,3,4
structure(list(gameid = c("ChicagoBoston19961101", "ChicagoBoston19961101",
"ChicagoBoston19961101", "ChicagoBoston19961101", "ChicagoBoston19961101",
"ChicagoBoston19961101", "ChicagoBoston19961101"), player_fg = c("D. Rodman",
"D. Wesley", "M. Jordan", "E. Williams", "S. Pippen", "S. Pippen",
"S. Pippen"), fg_result = c(1, 1, 0, 1, 1, 1, 1)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -7L), groups = structure(list(
gameid = "ChicagoBoston19961101", .rows = list(1:7)), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame"), .drop = FALSE))