Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204922

Finding the first number after consecutive zeros in data frame

$
0
0

I have a following data frame

data <- tibble(ID=rep(c(1:2), each= 9), time = rep(1:9, 2), event = c(1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,0,1,0))

I want to retrieve the first row for each subject which has "1" after the consecutive zeros i.e.row number 8 in the data.frame for first subject and row number 15 in the data.frame for the second subject


Viewing all articles
Browse latest Browse all 204922

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>