R: Is there a way to count the number of consecutive numbers in each row?
问题 I'm wondering if there's a way to count the number of consecutive numbers in each row. Ideally, the output will be in column V6 and count the number of consecutive numbers in columns V1-V5. For example, Row 1 - 1, 2, 3, 4, 5 since there are 5 consecutive numbers, the output will be 5. I've attached the dataset that I have below for your reference. Thanks. enter image description here 回答1: Here is an option where we get the difference between alternate columns by removing the first column,