Segment a dataframe according to consecutive identical values of a column expression.

segment_by(df, column, var = "segment")