Calculate Run Length Sequence and Maximum by Subject ID
问题 We have time series data in which repeated observations were measured for several subjects. I would like to calculate the number of occasions in which the variable positive == 1 occurs for each subject (variable id ). A second aim is to identify the maximum length of these runs of consecutive observations in which positive == 1 . For each subject there are likely to be multiple runs within the study period. Rather than calculating the maximum number of consecutive positive observations per