mark_first_in_each_group: Mark the first row in each group of rows.

Description Usage Arguments Value Examples

Description

Mark the first row in each group of rows.

Usage

1

Arguments

data

a data.frame ordered with respect to groups

group_cols

character names of the grouping columns

Value

numeric vector with index of first row in each group

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
d <- wrapr::build_frame(
    "g", "v" |
    1  , 1L  |
    0  , 2L  |
    0  , 3L  |
    1  , 4L  |
    1  , 5L  )

d <- d[wrapr::orderv(d), , drop = FALSE]
d$fi <- mark_first_in_each_group(d, "g")

print(d)

WinVector/FastBaseR documentation built on May 21, 2019, 4:04 a.m.