Relative Content

Tag Archive for rdplyrtidyverse

Creation of a custom grouping variable in R

I wanted to create a group variable with specific conditions based on the values of GT. If GT is ‘I’, it should generate a different number. If GT is ‘G’, the following rules should apply:

tidyverse: Custom row numbers

I want custom row numbers such that if consecutive As or Bs appear then the same ID will be repeated something like below: