Description Usage Arguments Details Author(s) See Also
Extracts specific records from within an id in a repeated measures data set.
1 2 3 4 5 | firstRecord(data, id, ...)
lastRecord(data, id, ...)
nthRecord(data, id, ..., n = 1)
|
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. |
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.
Benjamin Nutter
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.