FirstLastRecord: First, Last, and nth Records

Description Usage Arguments Details Author(s) See Also

Description

Extracts specific records from within an id in a repeated measures data set.

Usage

1
2
3
4
5
firstRecord(data, id, ...)

lastRecord(data, id, ...)

nthRecord(data, id, ..., n = 1)

Arguments

data

A data frame to be reduced to the first row per identifiers

id

a vector of identifiers

...

additional variables by which the data should be sorted prior to selecting the first per identifier set.

n

The record number to pull from each ID.

Details

The data frame will first be sorted by the variables in id and then by the variables in ....

Sorting is performed by the plyr::arrange function, and accepts use of the desc to sort a variable in descending order. In both firstRecord and lastRecord, sorting should be done in the natural sort order of the variable; the last record is identified using the duplicated function with fromLast=TRUE.

For nthRecord, using desc around each of the variables in ... will provide the nth-from-last record for each id.

Author(s)

Benjamin Nutter

See Also

order, duplicated


nutterb/Bluegrass documentation built on May 24, 2019, 10:50 a.m.